diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2019-10-08 14:07:50 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-10-08 14:07:50 +0200 |
commit | 71b268c7d962a819f88050c2567dced975aa249e (patch) | |
tree | 68d96786f1dc8ab00057781fad695577af57cbd8 | |
parent | 4527273f1c5bca044577f2f8ed2d7e4f203bf485 (diff) | |
download | busybox-w32-71b268c7d962a819f88050c2567dced975aa249e.tar.gz busybox-w32-71b268c7d962a819f88050c2567dced975aa249e.tar.bz2 busybox-w32-71b268c7d962a819f88050c2567dced975aa249e.zip |
ln: --no-target-directory implies --no-dereference
as in GNU coreutils
Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/ln.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/coreutils/ln.c b/coreutils/ln.c index ea2d10eab..5591e8335 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c | |||
@@ -41,7 +41,6 @@ | |||
41 | 41 | ||
42 | /* This is a NOEXEC applet. Be very careful! */ | 42 | /* This is a NOEXEC applet. Be very careful! */ |
43 | 43 | ||
44 | |||
45 | #define LN_SYMLINK (1 << 0) | 44 | #define LN_SYMLINK (1 << 0) |
46 | #define LN_FORCE (1 << 1) | 45 | #define LN_FORCE (1 << 1) |
47 | #define LN_NODEREFERENCE (1 << 2) | 46 | #define LN_NODEREFERENCE (1 << 2) |
@@ -63,7 +62,22 @@ int ln_main(int argc, char **argv) | |||
63 | int (*link_func)(const char *, const char *); | 62 | int (*link_func)(const char *, const char *); |
64 | 63 | ||
65 | opts = getopt32(argv, "^" "sfnbS:vT" "\0" "-1", &suffix); | 64 | opts = getopt32(argv, "^" "sfnbS:vT" "\0" "-1", &suffix); |
66 | 65 | /* | |
66 | -s, --symbolic make symbolic links instead of hard links | ||
67 | -f, --force remove existing destination files | ||
68 | -n, --no-dereference treat LINK_NAME as a normal file if it is a symbolic link to a directory | ||
69 | -b like --backup but does not accept an argument | ||
70 | --backup[=CONTROL] make a backup of each existing destination file | ||
71 | -S, --suffix=SUFFIX override the usual backup suffix | ||
72 | -v, --verbose | ||
73 | -T, --no-target-directory | ||
74 | -d, -F, --directory allow the superuser to attempt to hard link directories | ||
75 | -i, --interactive prompt whether to remove destinations | ||
76 | -L, --logical dereference TARGETs that are symbolic links | ||
77 | -P, --physical make hard links directly to symbolic links | ||
78 | -r, --relative create symbolic links relative to link location | ||
79 | -t, --target-directory=DIRECTORY specify the DIRECTORY in which to create the links | ||
80 | */ | ||
67 | last = argv[argc - 1]; | 81 | last = argv[argc - 1]; |
68 | argv += optind; | 82 | argv += optind; |
69 | argc -= optind; | 83 | argc -= optind; |
@@ -86,8 +100,11 @@ int ln_main(int argc, char **argv) | |||
86 | src = last; | 100 | src = last; |
87 | 101 | ||
88 | if (is_directory(src, | 102 | if (is_directory(src, |
89 | (opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE | 103 | /*followlinks:*/ !(opts & (LN_NODEREFERENCE|LN_LINKFILE)) |
90 | ) | 104 | /* Why LN_LINKFILE does not follow links: |
105 | * -T/--no-target-directory implies -n/--no-dereference | ||
106 | */ | ||
107 | ) | ||
91 | ) { | 108 | ) { |
92 | if (opts & LN_LINKFILE) { | 109 | if (opts & LN_LINKFILE) { |
93 | bb_error_msg_and_die("'%s' is a directory", src); | 110 | bb_error_msg_and_die("'%s' is a directory", src); |