The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how can unset for "PS4" koti_rama UNIX for Dummies Questions & Answers 1 08-05-2007 11:12 PM
Readonly access faruque.ahmed UNIX for Dummies Questions & Answers 13 01-31-2007 06:25 AM
How to unset 'finger' info? Chanakya.m Shell Programming and Scripting 3 01-23-2006 06:12 AM
Is there any way to set env variable in top level Makefile and unset when done umen Shell Programming and Scripting 0 10-23-2005 05:15 AM
Making files readonly with vi? Flyguy UNIX for Dummies Questions & Answers 2 11-15-2003 03:52 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-11-2007
Registered User
 

Join Date: Sep 2007
Posts: 9
how to unset the readonly variable

Hi All,


May be this is a very simple question...

[trainee@Venus trainee]$ b=8
[trainee@Venus trainee]$ readonly b
[trainee@Venus trainee]$ echo $b
8
[trainee@Venus trainee]$ b=90
-bash: b: readonly variable
[trainee@Venus trainee]$ unset b
-bash: unset: b: cannot unset: readonly variable


I m not able to change the readonly mode of variable b
Please help me out..

Thanks
Nidhi
Reply With Quote
Forum Sponsor
  #2  
Old 09-11-2007
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Tha man pages for bash says, once a variable is marked as readonly, it cannot be unset.

Code:
             typeset -r     Make names readonly.  These names cannot then be  assigned values by subsequent assignment statements or unset.
Also unset says

Code:
       unset [-fv] [name ...]
              For each name, remove the corresponding variable or function.  If
              no  options  are  supplied,  or the -v option is given, each name
              refers to a shell  variable.   Read-only  variables  may  not  be
              unset.
Your best option would be to kill the shell, or run the commands within a subshell. Something like

Code:
[/tmp]$ {(b=8; readonly b; echo "-$b-"); b=90; echo "[$b]"; unset b; echo "[[$b]]";}
-8-
[90]
[[]]
Reply With Quote
  #3  
Old 09-12-2007
Registered User
 

Join Date: Sep 2007
Posts: 9
Thanks Vino...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0