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,
Sonal.
"man setlocale"
But this is some kind of c library function. I want to use this in shell script.
export LC_ALL=POSIX
resets all of the locale settings to POSIX. The default setting is usually POSIX or C
locale settings are controlled by changing the set of locale envrionment variables:
LC_CTYPE="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_MESSAGES="C"
modifying variable ( locale ) LANG
controls other locale variables as well
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 ( ... ).
$ cat a.sh
A=OUTER
echo $A
(
A=INNER
echo $A
)
echo $A
$ ksh a.sh
OUTER
INNER
OUTER
In unix where the locale variables are defined.
How the LC_ALL is being referred.
Plz throw light on this.
setlocal or setlocale ? They are two different things.
setlocal is specific to Windows.
setlocale is common to Unix/Windows.
For setlocal, you are better off invoking the shell script as
sh myscript.sh or
./myscript.sh
You can also do what kahuna proposed.
The locale specific variables are all environment variables. Like LC_ALL, LANG can changed to any particular locale. Say for Japanese one possible setting is
export LC_ALL=ja_JP.euc_jp
export LANG=ja_JP.euc_jp