According to section 3.7.1 of the Bash manual, destination variables at the beginning of the command line should be visible to the program being called.
eg.
DIR=/tmp ls $DIR
should behave as if I typed "ls / tmp" - and the DIR variable should not be saved after the command is executed.
Cygwin Bash (GNU bash, version 3.2.51 (24) -release (i686-pc-cygwin)) does not seem to do this - the above command behaves as if $ DIR was not detected. Other tests, such as "DIR = / tmp echo $ DIR", "DIR = / tmp set", etc., confirm this.
Note that adding a semicolon ("DIR = / tmp; ls $ DIR"), but leaves the variable defined after the command.
Why is this not working as expected?
source
share