On 5/20/11 12:10 PM, Eric Blake wrote:
> On 05/20/2011 09:33 AM, Chet Ramey wrote:
>>> Well, that's rather all over the place, but yes, it does seem like bash
>>> was the buggiest of the lot, compared to other shells. Interactively, I
>>> tested:
>>>
>>> readonly x=1
>>> case 1 in $((x++)) ) echo hi1 ;; *) echo hi2; esac
>>> echo $x.$?
>>>
>>> bash 4.1 printed:
>>> bash: x: readonly variable
>>> hi1
>>> 1.0
>>> which means it matched '1' to $((x++)) before reporting the failure
>>> assign to x, and the case statement succeeded. Changing the first "1"
>>> to any other string printed hi2 (the * case).
>>
>> Thanks for the report. This was an easy fix. The variable assignment
>> error was actually handled correctly, the expression evaluation code
>> just didn't pay enough attention to the result.
>
> How about the even simpler:
>
> $ bash -c 'readonly x=5; echo $((x=5))'; echo $?
That's not simpler, that's exactly the same case: a variable assignment
error during expression evaluation for arithmetic expansion.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/