OS: Ubuntu 16.04.3
Shell: Bash 4.3.48
I know that is possible to temporarily change the content of a variable as in var=value command, being probably IFS= read -r var the most notable case of this.
And, thanks to Greg's wiki, I also understand:
# Why this
foo() { echo "$var"; }
var=value foo
# And this does work
var=value; echo "$var"
# But this doesn't
var=value echo "$var"
What escapes my understanding is this:
$ foo() { echo "${var[0]}"; }
$ var=(bar baz) foo
(bar baz)
As far as I know (and following the logic of previous examples), it should print bar, not (bar baz).
Does this only happen to me? Is this the intended behavior and I'm missing something? Or is this a bug?