>export FOOBAR=foobar; IFS=b echo ${FOOBAR}
I was expecting to see
foo ar
but I see
foobar
Why?
The IFS hasnt yet taken effect. add another ";":
FOOBAR=foobar IFS=b; echo ${FOOBAR}
In man bash section SIMPLE COMMAND EXPANSION
you can read (abbreviated):
When a simple command is executed
The words that the parser has marked as variable assignments (those preceding the command name) are saved for later processing.
The words that are not variable assignments or redirections are expanded.
...
The text after the = in each variable assignment ... [are] assigned to the variable.
so the IFS=b is done after expanding $FOOBAR.
IFS variable as was assigned, and wouldn't be seen after the command has been invoked. Otherwise, what would be the point of having this feature?[edit]I removed the technically incorrect answer.
http://tldp.org/LDP/abs/html/internalvariables.html "This variable determines how Bash recognizes fields, or word boundaries, when it interprets character strings."
[[ ]] or other special syntax suppressing that behavior); no loops needed.echo $FOOBAR does not, in and of itself, string-split the value in FOOBAR before passing those values to echo. This implication is incorrect.