commit a32d96cbf8b717710986e488b2adafb390b8600c
Author: sin <[email protected]>
Date:   Thu Jan 22 16:26:30 2015 +0000

    Handle ln -sf a foo/ correctly
    
    Previously it would not delete foo/a if it already existed.  Use
    unlinkat() instead to do that.

diff --git a/ln.c b/ln.c
index 0a5bf18..5942f01 100644
--- a/ln.c
+++ b/ln.c
@@ -67,7 +67,7 @@ main(int argc, char *argv[])
                if (!hasto)
                        to = basename(argv[0]);
                if (fflag)
-                       remove(to);
+                       unlinkat(dirfd, to, 0);
                if ((!sflag ? linkat(AT_FDCWD, argv[0], dirfd, to, flags)
                            : symlinkat(argv[0], dirfd, to)) < 0) {
                        eprintf("%s %s <- %s:", fname, argv[0], to);

Reply via email to