The UNIX Forums
"Join the Network of UNIX System Users"


 
Subject: equivalent command for setlocal in unix
ishan
Newbie
Rank: 1



UID 189
Digest Posts 0
Credits 0
Posts 72
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:32 AM  Profile | P.M. 
equivalent command for setlocal in unix



equivalent command for setlocal in unix




hi all,
is there any command in unix equivalent to setlocal in windows.
setlocal command is really useful in restoring local environment variables in windows.
thanks,


Top
Connections
Newbie
Rank: 1



UID 95
Digest Posts 0
Credits 0
Posts 21
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:32 AM  Profile | P.M. 
"man setlocale"
Top
Canadianbacon
Newbie
Rank: 1



UID 82
Digest Posts 0
Credits 0
Posts 32
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:32 AM  Profile | P.M. 
looking at the microsoft documentation

setlocal creates a local scope and endlocal terminates the local scope. any changes made within the setlocal and endlocal scope are discarded, thereby leaving the original environment unchanged. you can nest these two commands to a maximum of 32 levels. for more information about the setlocal and endlocal commands, see setlocal and endlocal

i think the closest equivalent effect can be created by spawning a subshell using ( ... ).

code:

$ cat a.sh
a=outer
echo $a
(
a=inner
echo $a
)
echo $a
$ ksh a.sh
outer
Top
 

 

All times are GMT, the time now is Mar 22, 2010 01:46 AM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.004893 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP