How to iterate through string one word at a time in zsh
问题 How do I modify the following code so that when run in zsh it expands $things and iterates through them one at a time? things="one two" for one_thing in $things; do echo $one_thing done I want the output to be: one two But as written above, it outputs: one two (I'm looking for the behavior that you get when running the above code in bash) 回答1: In order to see the behavior compatible with Bourne shell, you'd need to set the option SH_WORD_SPLIT : setopt shwordsplit # this can be unset by