patchThe GNU Bourne-Again SHell - Patches: patch #7818, Loop breaks when trying to write...

 
 

You are not allowed to post comments on this tracker with your current authentification level.

patch #7818: Loop breaks when trying to write to a readonly variable

Submitted by:  Daniel Amthor <danam21>
Submitted on:  Fri 13 Jul 2012 12:53:04 PM UTC  
 
Category: NonePriority: 5 - Normal
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open

Fri 13 Jul 2012 12:53:04 PM UTC, original submission:

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. Particularly an issue, when looping the the scripts in profile.d, should a variable be set twice by accident or if the scripts are sourced again by a script.

Latest version accessible:
~/test > bash --version
GNU bash, version 4.2.24(1)-release (x86_64-pc-linux-gnu)
on Ubuntu Precise.

Daniel Amthor <danam21>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by danam21 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup