[all from cvs head from this morning]

$ ./mksh -c 'echo "${1?}"'
./mksh: : parameter null or not set
$ ./mksh -c 'echo "${*?}"'
./mksh: : parameter null or not set
$ mksh /dev/stdin <<< 'set +h; echo "${-:?}"'
/dev/stdin[1]: : parameter null or not set

Note how the name of the parameter is not there

$ ./mksh -c 'echo "${#?}"'
1
$ ./mksh -c '(exit 123); echo ${#?}'
3
$ ./mksh -c 'echo ${#?unset}'
./mksh: ${#?unset}: bad substitution
$ bash -c 'echo ${#?unset}'
0
$ ksh -c 'echo ${#?unset}'
0
$ zsh -c 'echo ${#?unset}'
zsh:1: bad substitution
$ dash -c 'echo ${#?unset}'
0

Nobody would ever want to do that, but note how it's ambiguous
as it could be seen as ${#var} or as ${var?}.

$ ./mksh -uc 'echo "${a}"'
./mksh: a: parameter not set
$ ./mksh -c 'echo "${a?}"'
./mksh: a: parameter null or not set

The message is a bit misleading, you wouldn't get that message
if $a was set and null. It would be better if the message was
the same as for "set -u" here. The "null or not set" message
would be OK for ${var:?} (like in dash). ksh93's behaviour seems
to be the best behaviour (reports either "not set" or "null") .
bash behaves like mksh, zsh is worse as it says "not set" for
"a=;echo ${a:?}".

$ ./mksh -uc 'echo "${1:?}"' mksh ""
mksh: : parameter null or not set
$ ./mksh -uc 'echo "${*:?}"' mksh ""
zsh: segmentation fault  ./mksh -uc 'echo "${*:?}"' mksh ""
$ ./mksh -uc 'echo "${@:?}"' mksh ""
zsh: segmentation fault  ./mksh -uc 'echo "${@:?}"' mksh ""

-- 
Stephane

Reply via email to