To follow similar behavior than coreutils and busybox with this
GNU extension -T should only allow maximum of 2 arguments even
when accompanied with -f

touch a b
ln -sfT a b L


I had this fixed in my other patch on list already but Rob added his
own commit with
-T  so this is on top of current master.


-Jarno
From 3c60f334159296089a1332aa5cf49f52594c1695 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jarno=20M=C3=A4kip=C3=A4=C3=A4?= <jmaki...@gmail.com>
Date: Thu, 26 Sep 2019 08:47:40 +0300
Subject: [PATCH] ln: -T should allow only 2 arguments

To follow similar behavior than coreutils and busybox with this
GNU extension -T should only allow maximum of 2 arguments even
when accompanied with -f

touch a b
ln -sfT a b L

-Jarno
---
 toys/posix/ln.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/toys/posix/ln.c b/toys/posix/ln.c
index fb47e911..74b26f68 100644
--- a/toys/posix/ln.c
+++ b/toys/posix/ln.c
@@ -11,6 +11,7 @@ config LN
   default y
   help
     usage: ln [-sfnv] [FROM...] TO
+       or  ln [-sfnv] -T FROM TO
 
     Create a link between FROM and TO.
     One/two/many arguments work like "mv" or "cp".
@@ -41,7 +42,9 @@ 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) && toys.optc>1)
+      error_exit("-T max 2 args");
+    else if ((FLAG(T) && i) || (!i && toys.optc>1))
       error_exit("'%s' %s a directory", dest, i ? "is" : "not");
   } else buf.st_mode = 0;
 
-- 
2.19.1

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to