What controls the environment to know to split by space in zsh?
I'm sure it's something simple but in all my searching have yet to figure it out what controls it.
Trying to loop over items in a space-separated string like so:
s='foo bar baz'
for i in $s; do
echo "$i END"
done
# foo bar baz END
# ---
s='foo bar baz'
a=( $s )
echo ${a[0]} # (empty)
echo ${a[1]} # foo bar baz
# ---
s='foo bar baz'
IFS=' ' read a <<< $s
for i in "${a[@]}"; do
echo "$i END"
done
# foo bar baz END
The different methods work via sh and bash, but in a shell with oh-my-zsh I'm unable to separate by space, getting the results above. May not be oh-my-zsh - but looking to understand what drives this.
Working example from bash:
s='foo bar baz'
for i in $s; do
echo "$i END"
done
# foo END
# bar END
# baz END