3

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?
jesse_b
  • 37,005
  • 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
  • Related: https://unix.stackexchange.com/questions/443507/why-do-i-need-to-place-do-in-the-same-line-as-for – Kusalananda Jul 14 '18 at 07:36

0 Answers0