Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

15
  • Interesting that you do not mention (from the mascheck page you link to) zsh until release 4.3.0, in sh emulation mode (which means the option shwordsplit is set), does word splitting on the resulting arguments. and that the only version of bash (the only shell you specifically mention by name) that needs a very corner case addition is bash-4.0.0 ... -4.0.27. May we call that a little biased report? Commented Oct 3, 2016 at 15:02
  • @sorontar, I mention bash because that's the shell mentioned by the OP. For zsh in sh emulation there used to be a problem with ${1+"$@"}, not "$@" alone. Commented Oct 3, 2016 at 15:12
  • Exactly my point: there is a (somewhat corner case) issue also with zsh. Commented Oct 3, 2016 at 16:04
  • About for arg do (without the ;), the same mascheck page says: The original Almquist shell (ash) accepts all but the second variant.. Thus, the only really portable solution is for arg <newline> do. Commented Oct 3, 2016 at 16:10
  • @sorontar, the zsh issue you mention is not relevant to this Q&A, it's about the ${1+"$@"} construct which is not needed to loop over the positional parameters. My whole answer does say that for arg <newline> do is the most portable. I'm not sure I understand the point you're trying to make. Commented Oct 3, 2016 at 16:19