[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch #7818] Loop breaks when trying to write to a readonly variabl
From: |
Chet Ramey |
Subject: |
Re: [patch #7818] Loop breaks when trying to write to a readonly variable |
Date: |
Fri, 13 Jul 2012 10:05:20 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 |
On 7/13/12 8:53 AM, Daniel Amthor wrote:
> URL:
> <http://savannah.gnu.org/patch/?7818>
>
> Summary: Loop breaks when trying to write to a readonly
> variable
Yeah, that's an assignment error. Posix says a non-interactive shell
should exit in that case and that an interactive shell should write an
error message without exiting. Bash doesn't exit the shell, but it does
cause the current command to fail.
> In a construct like this:
>
> var=foo
> readonly var
> for num in 1 2 3 4 5
> do
> if [ $num -eq 3 ]
> then
> var=bar
> fi
> echo $num
> done
>
> the loop breaks in the third round, after trying to set the r/o variable.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/
- Re: [patch #7818] Loop breaks when trying to write to a readonly variable,
Chet Ramey <=