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

[BUG] emulate sh: arith assignment assigns variable type



When an assignment is done to an unset variable using an arithmetic
expression, zsh assigns a numerical or arithmetic type to that variable,
causing subsequent normal shell assignments to be interpreted as
arithmetic expressions.

This causes an incompatibility with other shells under 'emulate sh',
because the POSIX shell is supposed to be a typeless language. In sh
emulation mode, arithmetic assignment should not assign a variable type.

Steps to reproduce:

$ emulate sh
$ X=a:b:c
$ : $((X=1))	# no type assignment as variable was already et
$ X=a:b:c
$ unset X
$ : $((X=1))	# variable now restricted to arith expressions
$ X=a:b:c
zsh: bad math expression: ':' without '?'

Expected behaviour: the last assignment should succeed in sh emulation
mode (and does on all other shells).

Confirmed in zsh 4.1.1 through current.

Thanks, and happy new year.

- Martijn



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