diff options
author | Ethan Sommer <e5ten.arch@gmail.com> | 2019-09-29 03:11:03 -0400 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-09-30 12:57:35 -0500 |
commit | 14f5f890021b03211dc2228fb22b191e2671dd2d (patch) | |
tree | da056e34782893c9028325aff4777962ea5196ca /toys | |
parent | 9ea89dbb777246f907abe4fe1a4b3b1c255f21f0 (diff) | |
download | toybox-14f5f890021b03211dc2228fb22b191e2671dd2d.tar.gz |
Add ln -t
Diffstat (limited to 'toys')
-rw-r--r-- | toys/posix/ln.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/toys/posix/ln.c b/toys/posix/ln.c index f941290e..18a74d41 100644 --- a/toys/posix/ln.c +++ b/toys/posix/ln.c @@ -4,7 +4,7 @@ * * See http://opengroup.org/onlinepubs/9699919799/utilities/ln.html -USE_LN(NEWTOY(ln, "<1Tvnfs", TOYFLAG_BIN)) +USE_LN(NEWTOY(ln, "<1t:Tvnfs", TOYFLAG_BIN)) config LN bool "ln" @@ -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 TO treated as file + -t Create links in DIR -T TO always treated as file, max 2 arguments -v Verbose */ @@ -25,9 +26,13 @@ config LN #define FOR_ln #include "toys.h" +GLOBALS( + char *t; +) + void ln_main(void) { - char *dest = toys.optargs[--toys.optc], *new; + char *dest = TT.t ? TT.t : toys.optargs[--toys.optc], *new; struct stat buf; int i; @@ -42,7 +47,7 @@ void ln_main(void) if (!((FLAG(n)||FLAG(T)) ? lstat : stat)(dest, &buf)) { i = S_ISDIR(buf.st_mode); - if ((FLAG(T) && i) || (!i && toys.optc>1)) + if ((FLAG(T) && i) || (!i && (toys.optc>1 || TT.t))) error_exit("'%s' %s a directory", dest, i ? "is" : "not"); } else buf.st_mode = 0; |