Can anyone explain why the semi-colon is necessary in order for the LANG to be seen as updated by bash?Doesn't work:> LANG=Ja_JP bash -c echo $LANGen_USWorks:> LANG=Ja_JP ; bash -c echo $LANGJa_JPI'm working with both bash 4.1.10 on linux and the same version under cygwin
When to use a semi-colon between environment variables and a command
bash;shell script
Parameter and other types of expansions are performed when the command is read, before it is executed.The first version, LANG=Ja_JP bash -c echo $LANG, is a single command. After it is parsed as such, $LANG is expanded to en_US before anything is executed.  Once bash is finished processing the input, it forks a process, adds LANG=Ja_JP to the environment as expected, and then executes bash -c echo en_US.You can prevent expansion with single quotes, i.e. LANG=Ja_JP bash -c 'echo $LANG' outputs Ja_JP.Note that when you have a variable assignment as part of a command, the assignment only affects the environment of that command and not that of your shell.The second version, LANG=Ja_JP; bash -c echo $LANG is actually two separate commands executed in sequence.  The first is a simple variable assignment without a command, so it affects your current shell.Thus, your two snippets are fundamentally different despite the superficial distinction of a single ;.Completely off-topic, but might I recommend appending a .UTF-8 when setting LANG.  There's no good reason nowadays not to be using Unicode in the 21st century.