[hackers] [sbase] Handle ln -sf a foo/ correctly || sin
commit a32d96cbf8b717710986e488b2adafb390b8600c
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 Thu Jan 22 2015 - 17:27:08 CET
This archive was generated by hypermail 2.3.0
: Thu Jan 22 2015 - 17:36:09 CET