[hackers] [sbase] Handle ln -sf a foo/ correctly || sin

From: <git_AT_suckless.org>
Date: Tue, 24 Mar 2015 23:53:13 +0100 (CET)

commit d475a6bdf24f6a2c040def66676b5105b42d3b63
Author: sin <sin_AT_2f30.org>
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
_AT_@ -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);
Received on Tue Mar 24 2015 - 23:53:13 CET

This archive was generated by hypermail 2.3.0 : Wed Mar 25 2015 - 00:01:52 CET