Redirections are simply not parsed after word splitting with a variable. Only pathname expansion and similar stuffs are recognized.
With your example, >/dev/null
is treated literally there as if you ran:
">/dev/null" "false"
In which case, >
doesn't have a special meaning.
That is the reason why eval
is needed to re-evaluate the resulting arguments as a new command. Whatever you see with echo
is what you get with eval
.
# foo='>/dev/null'
# echo $foo true
>/dev/null true
So sometimes you also need to quote to prevent word splitting and other expansions before evaulation:
echo "$foo true"