3

This question already has an answer here:

While reading about 11.12 Limitations of Shell Builtins I came across the following:

To loop over positional arguments, use:

for arg
do
   echo "$arg"
done

You may not leave the do on the same line as for, since some shells improperly grok:

for arg; do
   echo "$arg"
done

It doesn't seem to explain anymore detail than that.

Questions

  • What shells have a problem with this syntax?
  • What is the problem?

marked as duplicate by ilkkachu, Community Feb 10 at 12:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Certainly not any of the usual suspects; this works fine with bash, dash, sh, fish, and zsh which are the only shells I have installed at the moment. – DopeGhoti Jul 13 '18 at 21:45
  • This mention has nothing to do with an approval because it concerns "Portable Shell Programming". Moreover, the term "improperly grok" expresses an opposite point of view. – Fólkvangr Jul 14 '18 at 9:55