Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[BUG] emulate sh: arith assignment assigns variable type
- X-seq: zsh-workers 37472
- From: Martijn Dekker <martijn@xxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [BUG] emulate sh: arith assignment assigns variable type
- Date: Fri, 01 Jan 2016 21:03:33 +0100
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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