diff --git a/NEWS b/NEWS index 53002d62e..fff087db3 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,11 @@ For full details, see the git log at: https://github.com/ksh93/ksh Any uppercase BUG_* names are modernish shell bug IDs. +2021-11-14: + +- Another test/[ fix: "test \( string1 -a string2 \)" and "test \( string1 -o + string2 \)" no longer give an incorrect "argument expected" error message. + 2021-11-13: - The test/[ built-in command now supports the '<' and '=~' operators from [[. diff --git a/src/cmd/ksh93/bltins/test.c b/src/cmd/ksh93/bltins/test.c index 24a35f91a..8449c839f 100644 --- a/src/cmd/ksh93/bltins/test.c +++ b/src/cmd/ksh93/bltins/test.c @@ -159,6 +159,7 @@ int b_test(int argc, char *argv[],Shbltin_t *context) if(!(argc==4 && (not=sh_lookup(cp=argv[2],shtab_testops)))) { cp = (++argv)[1]; + ++tdata.av; argc -= 2; } } @@ -320,7 +321,7 @@ static int e3(struct test *tp) else /* TEST_OR */ return(*arg || expr(tp,3)); } - if(arg && c_eq(arg, '!')) + if(arg && c_eq(arg, '!') && tp->ap < tp->ac) return(!e3(tp)); if(c_eq(arg, '(')) { diff --git a/src/cmd/ksh93/data/testops.c b/src/cmd/ksh93/data/testops.c index 678b951cd..9c13d6845 100644 --- a/src/cmd/ksh93/data/testops.c +++ b/src/cmd/ksh93/data/testops.c @@ -57,7 +57,7 @@ const Shtable_t shtab_testops[] = }; const char sh_opttest[] = -"[-1c?\n@(#)$Id: test (ksh 93u+m) 2021-11-13 $\n]" +"[-1c?\n@(#)$Id: test (ksh 93u+m) 2021-11-14 $\n]" "[--catalog?" SH_DICT "]" "[+NAME?test, [ - evaluate expression]" "[+DESCRIPTION?\btest\b evaluates expressions and returns its result using the " diff --git a/src/cmd/ksh93/include/version.h b/src/cmd/ksh93/include/version.h index 640b8d418..0421443d4 100644 --- a/src/cmd/ksh93/include/version.h +++ b/src/cmd/ksh93/include/version.h @@ -21,7 +21,7 @@ #define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */ #define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */ -#define SH_RELEASE_DATE "2021-11-13" /* must be in this format for $((.sh.version)) */ +#define SH_RELEASE_DATE "2021-11-14" /* must be in this format for $((.sh.version)) */ #define SH_RELEASE_CPYR "(c) 2020-2021 Contributors to ksh " SH_RELEASE_FORK /* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */ diff --git a/src/cmd/ksh93/tests/bracket.sh b/src/cmd/ksh93/tests/bracket.sh index 00e7baa0c..3d757e9f8 100755 --- a/src/cmd/ksh93/tests/bracket.sh +++ b/src/cmd/ksh93/tests/bracket.sh @@ -447,7 +447,19 @@ fi [ abc =~ 'a(b)c' ] 2>/dev/null || err_exit "[ abc =~ 'a(b)c' ] fails" [ abc =~ '\babc\b' ] 2>/dev/null || err_exit "[ abc =~ '\\babc\\b' ] fails" [ AATAAT =~ '(AAT){2}' ] 2>/dev/null || err_exit "[ AATAAT =~ '(AAT){2}' ] does not match" -[ AATAATCCCAATAAT =~ '(AAT){2}CCC(AAT){2}' ] || err_exit "[ AATAATCCCAATAAT =~ '(AAT){2}CCC(AAT){2}' ] does not match" +[ AATAATCCCAATAAT =~ '(AAT){2}CCC(AAT){2}' ] 2>/dev/null || err_exit "[ AATAATCCCAATAAT =~ '(AAT){2}CCC(AAT){2}' ] does not match" + +# string nonemptiness tests combined with -a/-o and parentheses +for c in "0:x -a x" "1:x -a ''" "1:'' -a x" "1:'' -a ''" \ + "0:x -o x" "0:x -o ''" "0:'' -o x" "1:'' -o ''" \ + "0:x -a !" "0:x -o !" "1:'' -a !" "0:'' -o !" +do e=${c%%:*} + c=${c#*:} + eval "[ \( $c \) ]" 2>/dev/null + (($?==e)) || err_exit "[ \( $c \) ] not working" + eval "test \( $c \)" 2>/dev/null + (($?==e)) || err_exit "test \( $c \) not working" +done # ====== exit $((Errors<125?Errors:125))