what is the meaning of FOOBAR=foobar followed by a shell command? -
i see in shell scripts variable assignment followed (without semicolon) command. meaning of that? not seem affect command, , not seem affect next command way normal assignment would:
>echo $foobar >foobar=1 echo $foobar >echo $foobar >
so, does do?
it sets environment variable value process.
here, step step, happens:
- original command:
foobar=1 echo $foobar
- shell performs substitution: command
foobar=1 echo
- shell
fork(2)
s new process - environment variable created in new process: command
echo
(with$foobar
equal1
) - new process
exec(3)
ed:\n
output - new process exits , reaped shell
at no point parent process see assigned value of $foobar
.
Comments
Post a Comment