sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 2a7c8c0aaf09cdc12b2e75bb43890c99bd224833
parent 93826701ba4a580d1423111a5df22be766c4c641
Author: Eivind Uggedal <eivind@uggedal.com>
Date:   Fri Jun  5 11:11:09 +0000

ln: allow dangling symlinks

Diffstat:
ln.c | 25++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/ln.c b/ln.c @@ -65,20 +65,23 @@ main(int argc, char *argv[]) if (!hastarget) target = basename(*argv); - if (stat(*argv, &st) < 0) { - weprintf("stat %s:", *argv); - ret = 1; - continue; - } else if (fstatat(dirfd, target, &tst, AT_SYMLINK_NOFOLLOW) < 0) { - if (errno != ENOENT) { - weprintf("fstatat %s %s:", targetdir, target); + if (!sflag) { + if (stat(*argv, &st) < 0) { + weprintf("stat %s:", *argv); + ret = 1; + continue; + } else if (fstatat(dirfd, target, &tst, AT_SYMLINK_NOFOLLOW) < 0) { + if (errno != ENOENT) { + weprintf("fstatat %s %s:", targetdir, target); + ret = 1; + continue; + } + } else if (st.st_dev == tst.st_dev && st.st_ino == tst.st_ino) { + weprintf("%s and %s/%s are the same file\n", + *argv, targetdir, target); ret = 1; continue; } - } else if (st.st_dev == tst.st_dev && st.st_ino == tst.st_ino) { - weprintf("%s and %s/%s are the same file\n", *argv, targetdir, target); - ret = 1; - continue; } if (fflag && unlinkat(dirfd, target, 0) < 0 && errno != ENOENT) {