Guest BooYah Posted December 26, 2002 Report Share Posted December 26, 2002 I have this script to open a Japanese terminal, but as soon as it's finished, ther terminal language resets to English. If I type the commands 1 by 1, the langauge stays Japanese. Why won't it stay Japanese if I use the script? #! /bin/bash # A script to open a Japanese console echo "Setting-up Japanese Console" export LC_ALL=ja_JP export LANG=ja_JP.eucJP export XMODIFIERS='@im=kinput2' kinput2 -wnn & echo $LANG Quote Link to comment Share on other sites More sharing options...
chalex20 Posted December 26, 2002 Report Share Posted December 26, 2002 I have this script to open a Japanese terminal, but as soon as it's finished, ther terminal language resets to English. If I type the commands 1 by 1, the langauge stays Japanese. Why won't it stay Japanese if I use the script? For one very simple reason - you can't pass environment variables "back" to parents - only "forward" to children. When you run the script, a separate shell is run, which gets all those variables ( LANG and such). When you run commands one by one, your current shell variables are reassigned. #! /bin/bash This /bin/bash runs to execute your script!!! # A script to open a Japanese consoleecho "Setting-up Japanese Console" export LC_ALL=ja_JP export LANG=ja_JP.eucJP export XMODIFIERS='@im=kinput2' And these variables would never get to your login shell!!! kinput2 -wnn &echo $LANG There is a way, though, to leave your terminal in Japanese. Don't run the script, but "source" it. . your_script_here And yes, it is exactly that : "dot space script name" :-) This way, your login shell and not a separate shell would run the script - the effect would be the same as of typing the commands one by one. Good luck! Quote Link to comment Share on other sites More sharing options...
Cannonfodder Posted December 26, 2002 Report Share Posted December 26, 2002 That's pretty cool, I didn't know about the . script file. I've used source filename with the full word source. Is that the same thing in terms of process environment variables? Quote Link to comment Share on other sites More sharing options...
aru Posted December 26, 2002 Report Share Posted December 26, 2002 That's pretty cool, I didn't know about the . script file. I've used source filename with the full word source. Is that the same thing in terms of process environment variables? EXACTLY the same, both "." and "source" are synonyms in bash. Both are bash builtins, and both are intended to read and execute commands from "filename" (as in "source filename" or ". filename") in the CURRENT SHELL CONTEXT; vs a normal script execution which creates a subshell. chalex20 explained it perfectly Side note: For what I know "." was a Bourne Shell Builtin, and "source" came later as a Bash Builtin, so if you want the maximun portability in a script you should use "." instead of "source" (It's me speaking? :shock: well, it could be comp.unix.shell's fault --- my new 'divetimento' ) Quote Link to comment Share on other sites More sharing options...
Guest BooYah Posted December 28, 2002 Report Share Posted December 28, 2002 AHH! I had no idea. Makes complete sense, though. Thanks for the tip. Quote Link to comment Share on other sites More sharing options...
chalex20 Posted December 28, 2002 Report Share Posted December 28, 2002 Side note: For what I know "." was a Bourne Shell Builtin, and "source" came later as a Bash Builtin, so if you want the maximun portability in a script you should use "." instead of "source" (It's me speaking? :shock: well, it could be comp.unix.shell's fault --- my new 'divetimento' ) source comes originally from the csh/tcsh land :-) Quote Link to comment Share on other sites More sharing options...
aru Posted December 28, 2002 Report Share Posted December 28, 2002 source comes originally from the csh/tcsh land :-) Thanks, I didn't know that (infact I don't know any other shell apart of bash) :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.