aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-12-18 10:25:02 -0600
committerRob Landley <rob@landley.net>2013-12-18 10:25:02 -0600
commitc4a8ce4fe303ff66f1cf2fd3d14aef303d25287e (patch)
treeb6cda5f40a4be2fd2f73a31c7e290f87150aaf38
parented9eac3967ed88262293aa395744194f8be294b0 (diff)
downloadtoybox-c4a8ce4fe303ff66f1cf2fd3d14aef303d25287e.tar.gz
ln -v support from Ashwini Sharma (comment tweak from me)
-rw-r--r--toys/posix/ln.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/toys/posix/ln.c b/toys/posix/ln.c
index d69aabf4..3c94e721 100644
--- a/toys/posix/ln.c
+++ b/toys/posix/ln.c
@@ -4,13 +4,13 @@
*
* See http://opengroup.org/onlinepubs/9699919799/utilities/ln.html
-USE_LN(NEWTOY(ln, "<1nfs", TOYFLAG_BIN))
+USE_LN(NEWTOY(ln, "<1vnfs", TOYFLAG_BIN))
config LN
bool "ln"
default y
help
- usage: ln [-sfn] [FROM...] TO
+ usage: ln [-sfnv] [FROM...] TO
Create a link between FROM and TO.
With only one argument, create link in current directory.
@@ -18,6 +18,7 @@ config LN
-s Create a symbolic link
-f Force the creation of the link, even if TO already exists
-n Symlink at destination treated as file
+ -v Verbose
*/
#define FOR_ln
@@ -49,14 +50,15 @@ void ln_main(void)
if (S_ISDIR(buf.st_mode)) new = xmsprintf("%s/%s", dest, basename(try));
else new = dest;
- /* Silently unlink the existing target. If it doesn't exist,
- * then we just move on */
+ // Silently unlink the existing target (if any)
if (toys.optflags & FLAG_f) unlink(new);
rc = (toys.optflags & FLAG_s) ? symlink(try, new) : link(try, new);
if (rc)
perror_exit("cannot create %s link from '%s' to '%s'",
(toys.optflags & FLAG_s) ? "symbolic" : "hard", try, new);
+ else if (toys.optflags & FLAG_v)
+ fprintf(stderr, "'%s' -> '%s'\n", new, try);
if (new != dest) free(new);
}
}