On 08/09/2021 08:15, Oğuz via austin-group-l at The Open Group wrote:
Sorry for butting in, but according to the standard, is there really a
syntax error in the following?

sh -c ': << do | for x in xxx
do
do echo $x
done'

busybox sh, dash, gwsh, netbsd sh, and freebsd sh complain about a
missing `done'.

This is not about 'do' as a delimiter, but about a heredoc right after the items in a for command. This fails too:

  sh -c ': << x | for x in xxx
  x
  do echo $x
  done'

It results in an error about a missing 'do'. And this works, but should not:

  sh -c ': << x | for x in xxx
  do echo $x
  x
  done'

Only speaking for gwsh, but yes, I consider this is a bug and will make sure to fix it. What's happening is a missing check for pending heredocs, causing the heredoc to only start on line 3, rather than on line 2 as it should. There is nothing that I am aware of in POSIX that allows this.

Cheers,
Harald van Dijk

  • Re: shell: swappi... Geoff Clare via austin-group-l at The Open Group
  • Re: shell: swappi... Robert Elz via austin-group-l at The Open Group
    • Re: shell: s... G. Branden Robinson via austin-group-l at The Open Group
    • Re: shell: s... Robert Elz via austin-group-l at The Open Group
    • Re: shell: s... Geoff Clare via austin-group-l at The Open Group
    • Re: shell: s... Robert Elz via austin-group-l at The Open Group
      • Re: shel... Geoff Clare via austin-group-l at The Open Group
      • Re: shel... Robert Elz via austin-group-l at The Open Group
        • Re: ... Oğuz via austin-group-l at The Open Group
          • ... Joerg Schilling via austin-group-l at The Open Group
          • ... Harald van Dijk via austin-group-l at The Open Group
            • ... Oğuz via austin-group-l at The Open Group
          • ... Robert Elz via austin-group-l at The Open Group
        • Re: ... Geoff Clare via austin-group-l at The Open Group
        • Re: ... Robert Elz via austin-group-l at The Open Group

Reply via email to