aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-04-11 20:29:59 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-04-11 20:29:59 +0200
commit478b5ac2bcdb5014d8e6a6e8d7647b4c599cc1a7 (patch)
treef4d1752749ae697f126e02e51e0b1e2f6b8ba464
parentcb57abb46f06f4ede8d9ccbdaac67377fdf416cf (diff)
downloadbusybox-w32-478b5ac2bcdb5014d8e6a6e8d7647b4c599cc1a7.tar.gz
busybox-w32-478b5ac2bcdb5014d8e6a6e8d7647b4c599cc1a7.tar.bz2
busybox-w32-478b5ac2bcdb5014d8e6a6e8d7647b4c599cc1a7.zip
seq: fix yet another case of negative parameters not working
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/seq.c8
-rwxr-xr-xtestsuite/seq.tests1
2 files changed, 7 insertions, 2 deletions
diff --git a/coreutils/seq.c b/coreutils/seq.c
index c0e2d1e06..77a8aba8a 100644
--- a/coreutils/seq.c
+++ b/coreutils/seq.c
@@ -57,8 +57,12 @@ int seq_main(int argc, char **argv)
57 saved = argv[++n]; 57 saved = argv[++n];
58 if (!saved) 58 if (!saved)
59 break; 59 break;
60 if (saved[0] != '-') 60 if (saved[0] != '-') {
61 break; 61 // break; // "seq -s : -1 1" won't be treated correctly
62 continue;
63 }
64// "seq -s -1 1 9" is not treated correctly, but such usage
65// (delimiter string which looks like negative number) is very unlikely
62 c = saved[1]; 66 c = saved[1];
63 if (c == '.' || (c >= '0' && c <= '9')) { 67 if (c == '.' || (c >= '0' && c <= '9')) {
64 argv[n] = NULL; 68 argv[n] = NULL;
diff --git a/testsuite/seq.tests b/testsuite/seq.tests
index d414169c9..d0da8c119 100755
--- a/testsuite/seq.tests
+++ b/testsuite/seq.tests
@@ -45,5 +45,6 @@ testing "seq count by .3 with padding 2" "seq -w 03 .3 0004" "0003.0\n0003.3\n00
45 45
46testing "seq from -4 count down by 2" "seq -4 -2 -8" "-4\n-6\n-8\n" "" "" 46testing "seq from -4 count down by 2" "seq -4 -2 -8" "-4\n-6\n-8\n" "" ""
47testing "seq from -.0 count down by .25" "seq -.0 -.25 -.9" "-0.00\n-0.25\n-0.50\n-0.75\n" "" "" 47testing "seq from -.0 count down by .25" "seq -.0 -.25 -.9" "-0.00\n-0.25\n-0.50\n-0.75\n" "" ""
48testing "seq -s : with negative start" "seq -s : -1 1" "-1:0:1\n" "" ""
48 49
49exit $FAILCOUNT 50exit $FAILCOUNT