I am trying to understand how posix shell behave when command is in the form,
# variable assignment followed by a shell built-ins.
var=value shell_builtins;
in scenario like this, posix manual says,
if the command name is a special built-in utility, variable assignments shall affect the current execution environment. source
to me this seems to indicate that variable var
will be accessible for all the later command in the same command line session. However,
$var=value pwd
/home/red
$echo ${var}
#prints nothing
what am I missing?
I also tried bash in posix mode with bash --posix
. Result is same.
pwd
is not a special built-in utility. Special built-in utilities are break
, :
, continue
, .
, eval
, exec
, exit
, export
, readonly
, set
, shift
, times
, trap
, and unset
. See:
$ set -o posix
$ unset x
$ x=y shift 0
$ echo $x
y