summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2011-03-21 12:36:35 +0100
committerDenys Vlasenko2011-03-21 12:36:35 +0100
commitb0e8ced3589c601ad5c15e74d6f82b1928e1eb8f (patch)
treebe5e6987b72e57a0a098709bb7c3280da24b8026
parent32176ccec4eb1a3bc26b0217fa8d23f6ff44fab8 (diff)
downloadbusybox-b0e8ced3589c601ad5c15e74d6f82b1928e1eb8f.zip
busybox-b0e8ced3589c601ad5c15e74d6f82b1928e1eb8f.tar.gz
ln: explain why we use xstrdup
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/ln.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/coreutils/ln.c b/coreutils/ln.c
index ddad120..6da290c 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -40,8 +40,12 @@ int ln_main(int argc, char **argv)
last = argv[argc - 1];
argv += optind;
- if (argc == optind + 1) {
+ if (!argv[1]) {
+ /* "ln PATH/TO/FILE" -> "ln PATH/TO/FILE FILE" */
*--argv = last;
+ /* xstrdup is needed: "ln -s PATH/TO/FILE/" is equivalent to
+ * "ln -s PATH/TO/FILE/ FILE", not "ln -s PATH/TO/FILE FILE"
+ */
last = bb_get_last_path_component_strip(xstrdup(last));
}