On 1/4/11 10:05 AM, Eric Blake wrote:
> On 01/03/2011 11:41 PM, Jan Schampera wrote:
>> Hello list,
>>
>>
>> the read builtin command, when trying to assign to a readonly variable
>> after reading the data, spits an error message. This is fine.
>>
>> But the return status is 0. It "always" (down to 2.04 was tested) has
>> been like that, and it's like that in upcoming 4.2.
>>
>> For me, this doesn't make sense. The read may have been successful, but
>> the data is gone. It would make sense to return !=0 here, IMHO.
> 
> getopts also suffers from a difference in behavior between shells on
> readonly arguments:
> 
> $ ksh -c 'readonly foo; getopts a: foo -a blah; echo $?'
> ksh[1]: ksh: foo: is read only
> $ echo $?
> 2
> $ bash -c 'readonly foo; getopts a: foo -a blah; echo $?'
> bash: foo: readonly variable
> 1
> 
> where non-interactive ksh completely exited on an invalid assignment,
> but bash merely set $?.

The shell should not exit on an assignment error with getopts, since
getopts is not a special builtin.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to