Consider this snippet:
$ SOMEVAR=AAA
$ echo zzz $SOMEVAR zzz
zzz AAA zzz
Here I've set $SOMEVAR
to AAA
on the first line - and when I echo it on the second line, I get the AAA
contents as expected.
But then, if I try to specify the variable on the same command line as the echo
:
$ SOMEVAR=BBB echo zzz $SOMEVAR zzz
zzz AAA zzz
... I do not get BBB
as I expected - I get the old value (AAA
).
Is this how things are supposed to be? If so, how come then you can specify variables like LD_PRELOAD=/... program args ...
and have it work? What am I missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…