This second patch should fix the -T allow only 2 args All the previous test cases seems to pass. Should write test cases for this.
-Jarno On Wed, Sep 25, 2019 at 11:40 PM Ryan Prichard <rprich...@google.com> wrote: > > It looks like coreutils and busybox allow only 2 args with -T. Do we need to > diagnose this? > > touch A B > ln -sfT A B L > ln: extra operand 'L' > > busybox ln -sfT A B L > ln: -T accepts 2 args max > > toybox ln -sfT A B L > ls -l L > lrwxrwxrwx 1 rprichard primarygroup 1 Sep 25 13:38 L -> B > > With this patch, ln is overwriting the symlink twice, leaving it pointing at > B. > > -Ryan > > > On Wed, Sep 25, 2019 at 1:21 PM Jarno Mäkipää <jmaki...@gmail.com> wrote: >> >> Added: -T >> Replaced: & flag_# with FLAG(#) >> >> There was feature request on github. Apparently there is some android >> scripts with ln -sfT >> >> >> -Jarno >> _______________________________________________ >> Toybox mailing list >> Toybox@lists.landley.net >> http://lists.landley.net/listinfo.cgi/toybox-landley.net
From 049f57fc0b1d10327e773e95e3402e2b2e2d3a00 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 00:10:36 +0300 Subject: [PATCH 2/2] ln: fix -T to accept only 2 args --- toys/posix/ln.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toys/posix/ln.c b/toys/posix/ln.c index 7d5ade99..d636d296 100644 --- a/toys/posix/ln.c +++ b/toys/posix/ln.c @@ -39,7 +39,8 @@ void ln_main(void) // Is destination a directory? if (FLAG(T)) { lstat(dest, &buf); - if (S_ISDIR(buf.st_mode)) error_exit("'%s' is a directory", dest); + if (toys.optc >= 2) error_exit("-T allows only 2 args"); + else if (S_ISDIR(buf.st_mode)) error_exit("'%s' is a directory", dest); } else if (((FLAG(n)) ? lstat : stat)(dest, &buf) || !S_ISDIR(buf.st_mode)) -- 2.19.1
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net