ARG_MAX
| Shells
| whatshell
| portability
| permissions
| UUOC
| ancient
| -
| ../Various
| HOME
$@"
| echo/printf
| set -e
| test
| tty defs
| tty chars
| $() vs )
| IFS
| using siginfo
| nanosleep
| line charset
| locale
test" operator robustness in various shells 2010-01-08 (see recent changes)
Variations in the handling of arguments to test among the various traditional and POSIX conformant implementations.
| command | sh V7 | sh Sys3 | sh SVR2 Ultrix | sh SVR3 sunos413 | sh SVR4 -sunos510 | ksh86a epix | ksh88i sunos59 | ksh93-t | pdksh- 5.2.14 | posh- 0.5.4 | posh- 0.6.17 | bash- 1.14.7 | bash-4.1 | ash-orig | ash-0.2-linux | ash-0.3.4 | dash- 0.4.26 | dash- 0.5.5.1 | zsh- 4.0.4 | zsh- 4.3.9 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| a=x; test -n "$a" && echo test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 | test1 |
| a=!; test -n "$a" || echo nok | ||||||||||||||||||||
| a==; test -n "$a" || echo nok | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | ||||||||||||||
| a=-; test -n "$a" || echo nok | ||||||||||||||||||||
| a=-n; test -n "$a" || echo nok | ||||||||||||||||||||
| a='('; test -n "$a" || echo nok | syn error | |||||||||||||||||||
| a=x; b=x; test "$a" = "$b" && echo test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 | test2 |
| a=x; b=!; test "$a" = "$b" && echo nok | ||||||||||||||||||||
| a=x; b==; test "$a" = "$b" && echo nok | ||||||||||||||||||||
| a=x; b=-; test "$a" = "$b" && echo nok | ||||||||||||||||||||
| a=x; b=-n; test "$a" = "$b" && echo nok | ||||||||||||||||||||
| a=x; b='('; test "$a" = "$b" && echo nok | syn error | |||||||||||||||||||
| a=!; b=x; test "$a" = "$b" && echo nok | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | unary op exp | syn error | unexp op | unexp op | |||||||||
| a=!; b=!; test "$a" = "$b" || echo nok | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | unary op exp | syn error | unexp op | unexp op | |||||||||
| a=!; b==; test "$a" = "$b" && echo nok | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | unary op exp | syn error | arg exp | arg exp | |||||||||
| a=!; b=-; test "$a" = "$b" && echo nok | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | unary op exp | syn error | unexp op | unexp op | |||||||||
| a=!; b=-n; test "$a" = "$b" && echo nok | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | unary op exp | syn error | unexp op | unexp op | |||||||||
| a==; b=x; test "$a" = "$b" && echo nok | ||||||||||||||||||||
| a==; b=!; test "$a" = "$b" && echo nok | ||||||||||||||||||||
| a==; b==; test "$a" = "$b" || echo nok | ||||||||||||||||||||
| a==; b=-; test "$a" = "$b" && echo nok | ||||||||||||||||||||
| a==; b=-n; test "$a" = "$b" && echo nok | ||||||||||||||||||||
| a=-; b=x; test "$a" = "$b" && echo nok | ||||||||||||||||||||
| a=-; b=!; test "$a" = "$b" && echo nok | ||||||||||||||||||||
| a=-; b==; test "$a" = "$b" && echo nok | ||||||||||||||||||||
| a=-; b=-; test "$a" = "$b" || echo nok | ||||||||||||||||||||
| a=-; b=-n; test "$a" = "$b" && echo nok | ||||||||||||||||||||
| a=-n; b=x; test "$a" = "$b" && echo nok | nok | syn error | unexp op | |||||||||||||||||
| a=-n; b=!; test "$a" = "$b" && echo nok | nok | syn error | unexp op | |||||||||||||||||
| a=-n; b==; test "$a" = "$b" && echo nok | nok | syn error | unexp op | |||||||||||||||||
| a=-n; b=-; test "$a" = "$b" && echo nok | nok | syn error | unexp op | |||||||||||||||||
| a=-n; b=-n; test "$a" = "$b" || echo nok | syn error | unexp op | ||||||||||||||||||
| a=x; b=x; test -n "$a" -a -n "$b" && echo test3 | test3 | test3 | test3 | test3 | test3 | test3 | test3 | test3 | test3 | unexp op | test3 | test3 | test3 | test3 | test3 | test3 | test3 | test3 | test3 | test3 |
| a=x; b=!; test -n "$a" -a -n "$b" || echo nok | unexp op | |||||||||||||||||||
| a=x; b==; test -n "$a" -a -n "$b" || echo nok | syn error | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | unexp op | ||||||||||||
| a=x; b=-; test -n "$a" -a -n "$b" || echo nok | unexp op | |||||||||||||||||||
| a=x; b=-n; test -n "$a" -a -n "$b" || echo nok | unexp op | |||||||||||||||||||
| a=!; b=x; test -n "$a" -a -n "$b" || echo nok | unexp op | syn error | ||||||||||||||||||
| a=!; b=!; test -n "$a" -a -n "$b" || echo nok | arg exp | unexp op | syn error | |||||||||||||||||
| a=!; b==; test -n "$a" -a -n "$b" || echo nok | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | unexp op | syn error | ||||||||||||
| a=!; b=-; test -n "$a" -a -n "$b" || echo nok | unexp op | syn error | ||||||||||||||||||
| a=!; b=-n; test -n "$a" -a -n "$b" || echo nok | unexp op | syn error | ||||||||||||||||||
| a==; b=x; test -n "$a" -a -n "$b" || echo nok | arg exp | nok | too many args | nok | syn error | nok | nok | unexp op | too many args | too many args | extra arg -n | unexp op | unexp op | too many args | ||||||
| a==; b=!; test -n "$a" -a -n "$b" || echo nok | nok | too many args | nok | syn error | nok | nok | unexp op | too many args | too many args | extra arg -n | unexp op | unexp op | too many args | |||||||
| a==; b==; test -n "$a" -a -n "$b" || echo nok | nok | too many args | nok | syn error | nok | nok | unexp op | too many args | too many args | extra arg -n | unexp op | unexp op | too many args | |||||||
| a==; b=-; test -n "$a" -a -n "$b" || echo nok | syn error | nok | too many args | nok | syn error | nok | nok | unexp op | too many args | too many args | extra arg -n | unexp op | unexp op | too many args | ||||||
| a==; b=-n; test -n "$a" -a -n "$b" || echo nok | syn error | nok | too many args | nok | syn error | nok | nok | unexp op | too many args | too many args | extra arg -n | unexp op | unexp op | too many args | ||||||
| a=-; b=x; test -n "$a" -a -n "$b" || echo nok | syn error | unexp op | ||||||||||||||||||
| a=-; b=!; test -n "$a" -a -n "$b" || echo nok | syn error | unexp op | ||||||||||||||||||
| a=-; b==; test -n "$a" -a -n "$b" || echo nok | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | unexp op | |||||||||||||
| a=-; b=-; test -n "$a" -a -n "$b" || echo nok | arg exp | unexp op | ||||||||||||||||||
| a=-; b=-n; test -n "$a" -a -n "$b" || echo nok | unexp op | |||||||||||||||||||
| a=-n; b=x; test -n "$a" -a -n "$b" || echo nok | unexp op | syn error | ||||||||||||||||||
| a=-n; b=!; test -n "$a" -a -n "$b" || echo nok | unexp op | syn error | ||||||||||||||||||
| a=-n; b==; test -n "$a" -a -n "$b" || echo nok | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | arg exp | unexp op | syn error | |||||||||||
| a=-n; b=-; test -n "$a" -a -n "$b" || echo nok | unexp op | syn error | ||||||||||||||||||
| a=-n; b=-n; test -n "$a" -a -n "$b" || echo nok | unexp op | syn error | ||||||||||||||||||
| command | sh V7 | sh Sys3 | sh SVR2 Ultrix | sh SVR3 sunos413 | sh SVR4 -sunos510 | ksh86a epix | ksh88i sunos59 | ksh93-t | pdksh- 5.2.14 | posh- 0.5.4 | posh- 0.6.17 | bash- 1.14.7 | bash-4.1 | ash-orig | ash-0.2-linux | ash-0.3.4 | dash- 0.4.26 | dash- 0.5.5.1 | zsh- 4.0.4 | zsh- 4.3.9 |
About the table:
[[...]] is not required by POSIX (but allowed),
sh ... shell varinats in the table,
$ cat tests
a=x; test -n "$a" && echo test1
a=!; test -n "$a" || echo nok
[...]
$ cat loop
while IFS= read -r line ; do
{print HTML}
for i in {shells}
do
log=`$i -ec "$line" 2>&1`; ret=$?
log=`printf '%s' "$log"|tr -d '\n'`
printf {HTML with "$log"}
done
done < tests
...and then piped through sed to substitute the error messages.
<mascheck@in-ulm.de>
<http://www.in-ulm.de/~mascheck/various/test/>