Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[bug] shift: shell exits with status 0 on bad math expression



When an argument is given to 'shift' that constitutes a bad math expression, the (sub)shell prints an error and exits, but the exit status is zero (= success) under most conditions.

$ zsh -c 'shift @/@'; echo $?
zsh:1: bad math expression: illegal character: @
0
$ zsh -c 'builtin shift @/@'; echo $?
zsh:1: bad math expression: illegal character: @
0
$ zsh -c 'emulate sh; shift @/@'; echo $?
zsh:1: bad math expression: illegal character: @
1
$ zsh -c 'emulate sh; command shift @/@'; echo $?
zsh:1: bad math expression: illegal character: @
0

The exit status should be non-zero in all cases.

The behaviour is the same from current git down to zsh 5.0.7, the earliest version I tested.

- M.



Messages sorted by: Reverse Date, Date, Thread, Author