Re: [Debian#1037195] dash: $(here-doc in <<substitution) is always empty, must consume subsequent lines per POSIX?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/06/2023 10:06, Herbert Xu wrote:
наб <nabijaczleweli@xxxxxxxxxxxxxxxxxx> wrote:

POSIX Issue 7, XCU, 2. Shell Command Language says
   2.7.4 Here-Document
The redirection operators "<<" and "<<-" both allow redirection of subsequent lines read by the shell to the input of a command. The redirected lines are known as a "here-document". The here-document shall be treated as a single word that begins after the next <newline> and continues until there is a line containing only the delimiter and a <newline>, with no <blank> characters in between. Then the next here-document starts, if there is one. The format is as follows:
and its counterpart in Issue 8 Draft 3
  80601  2.7.4 Here-Document
  80602  The redirection operators "<<" and "<<-" both allow redirection of subsequent lines read by
  80603  the shell to the input of a command. The redirected lines are known as a ``here-document’’.
  80604  The here-document shall be treated as a single word that begins after the next NEWLINE token
  80605  and continues until there is a line containing only the delimiter and a <newline>, with no
  80606  <blank> characters in between. Then the next here-document starts, if there is one. For the
  80607  purposes of locating this terminating line, the end of a command_string operand (see sh) shall be
  80608  treated as a <newline> character, and the end of the commands string in $(commands) and
  80609  `commands` may be treated as a <newline>. If the end of input is reached without finding the
  80610  terminating line, the shell should, but need not, treat this as a redirection error. The format is as
  80611  follows:

I don't know.  It sounds like someone has changed the standard
to support what you want it to do, but at the same time the old
behaviour is still allowed.  This is because the text uses the
word may instead of must.

"what you want it to do"? What dash is doing is not what I want from a shell. I did say I did differently in my own. I am only saying dash's behaviour is permitted by POSIX.

This particular bit of the change to POSIX is to say something about things like

sh -c 'cat <<EOF
hello'

The lack of terminator was often silently ignored, and POSIX wants to encourage implementations to do differently. This part was not about command substitutions.

Does anyone have a link to the discussion around this change so
we can infer the intention?

https://austingroupbugs.net/view.php?id=1036
https://austingroupbugs.net/view.php?id=1521

Cheers,
Harald van Dijk



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux