projects
/
oweals
/
busybox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
32176cc
)
ln: explain why we use xstrdup
author
Denys Vlasenko
<vda.linux@googlemail.com>
Mon, 21 Mar 2011 11:36:35 +0000
(12:36 +0100)
committer
Denys Vlasenko
<vda.linux@googlemail.com>
Mon, 21 Mar 2011 11:36:35 +0000
(12:36 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
coreutils/ln.c
patch
|
blob
|
history
diff --git
a/coreutils/ln.c
b/coreutils/ln.c
index ddad120d11c25722f0080c17064b6d73be1ad68b..6da290c11182ee73d678f282af153cf24d014996 100644
(file)
--- 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));
}