Unexpected behavior in Bash
- by cYrus
From man bash:
A simple command is a sequence of optional variable assignments
followed by blank-separated words and redirections, and
terminated by a control operator. The first word specifies the
command to be executed, and is passed as argument zero. The
remaining words are passed as arguments to the invoked command.
So it's perfectly legal to write:
foo=bar echo $foo
but it doesn't work as I expect (it prints just a newline). It's quite strange to me since:
$ foo=bar printenv
foo=bar
TERM=rxvt-unicode
[...]
Could someone please explain me where I'm doing wrong?