Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham
	autolearn_force=no version=3.4.0
Message-ID: <5686DB95.2090602@inlv.org>
Date: Fri, 01 Jan 2016 21:03:33 +0100
From: Martijn Dekker <martijn@inlv.org>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
MIME-Version: 1.0
To: zsh-workers@zsh.org
Subject: [BUG] emulate sh: arith assignment assigns variable type
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Seq: zsh-workers 37472

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

