bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read builtin and readonly variables


From: Chet Ramey
Subject: Re: read builtin and readonly variables
Date: Tue, 04 Jan 2011 11:52:50 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7

On 1/4/11 10:35 AM, Eric Blake wrote:

>> The shell should not exit on an assignment error with getopts, since
>> getopts is not a special builtin.
> 
> Good point - 'unset' is different than 'getopts' or 'read' when it comes
> to special builtin status, and I agree that only special builtins are
> allowed to exit a non-interactive shell on an assignment error (POSIX
> XBD 2.8.1 Consequences of Shell Errors).  Even worse, neither ksh nor
> bash exit the shell on 'readonly foo; unset foo; echo $?', so ksh's
> behavior on 'getopts' seems like a ksh bug.

Unsetting a readonly variable does not constitute an assignment error or a
so-called `operand error'.  Nor is it a syntax error.

`unset' should return a non-zero status, since the variable could not be
unset, but not cause the shell to abort.

Chet

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]