zsh-workers
 help / color / mirror / code / Atom feed
* [BUG] emulate sh: arith assignment assigns variable type
@ 2016-01-01 20:03 Martijn Dekker
  2016-01-02 18:11 ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Martijn Dekker @ 2016-01-01 20:03 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-01-13  3:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-01 20:03 [BUG] emulate sh: arith assignment assigns variable type Martijn Dekker
2016-01-02 18:11 ` Peter Stephenson
2016-01-02 19:37   ` Mikael Magnusson
2016-01-02 20:46   ` Bart Schaefer
2016-01-02 21:12     ` Peter Stephenson
2016-01-13  3:13   ` Martijn Dekker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).