mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix [ \( str -a str \) ], [ \( str -o str \) ]
Symptoms: $ test \( string1 -a string2 \) /usr/local/bin/ksh: test: argument expected $ test \( string1 -o string2 \) /usr/local/bin/ksh: test: argument expected The parentheses should be irrelevant and this should be a test for the non-emptiness of string1 and/or string2. src/cmd/ksh93/bltins/test.c: - b_test(): There is a block where the case of 'test' with five or less arguments, the first and last one being parentheses, is special-cased. The parentheses are removed as a workaround: argv is increased to skip the opening parenthesis and argc is decreased by 2. However, there is no corresponding increase of tdata.av which is a copy of this function's argv. This renders the workaround ineffective. The fix is to add that increase. - e3(): Do not handle '!' as a negator if not followed by an argument. This allows a right-hand expression that is equal to '!' (i.e. a test for the non-emptiness of the string '!').
This commit is contained in:
parent
802136a6ad
commit
d9f1fdaa41
5 changed files with 22 additions and 4 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue