[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fix exit status of expr version of as_func_arith.
From: |
Eric Blake |
Subject: |
Re: Fix exit status of expr version of as_func_arith. |
Date: |
Sun, 16 Nov 2008 14:27:44 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Ralf Wildenhues on 11/16/2008 2:22 PM:
>> $ echo $((+))
>> bash: +: syntax error: operand expected (error token is "+")
>> $ echo $?
>> 0
>>
>> so we can't really make as_func_arith a reliable way to detect ill-formed
>> input.
>
> Hmm, bash 3.2.39 here does, as does zsh 4.3.6. OTOH, pdksh doesn't
> output an error neither change the status.
I spoke a bit too soon. Bash _does_ set $?, but fails to set $PIPESTATUS
(I have $PIPESTATUS in my PS1, and it is annoying when the two disagree).
So although my claim was false about $?, I was correct that bash has a bug.
$ PS1='${PIPESTATUS[*]} \$ '
0 $ echo $?
0
0 $ echo $((+))
bash: +: syntax error: operand expected (error token is "+")
0 $ echo $?
1
0 $ false
1 $
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkkgkFAACgkQ84KuGfSFAYDf9wCcDK+ca+snte4b+eH/yCCORfY3
opEAn24ZX770EE074wa4kltfzXg+F/a5
=DFxG
-----END PGP SIGNATURE-----