Skip to main content
remove the chatter, add link to the initial brief answer by the maintainer
Source Link
ilkkachu
  • 148k
  • 16
  • 268
  • 441

@MichaelMrozek The previous answer did not link to a thread started by the asker. The askerThis was asked aon Bash's mailing list question, and the answer wasthe maintainer confirmed it was a bug

They also mentioned that the text in POSIX "is not necessarily ambiguous, but it was a bugdoes require close reading. The asker did not follow-up", so I asked for a clarification on that mailing list discussion. I posted a new mailing list thread last night to follow-up with the Bash maintainer, and he responded with exactly an answer to this question. How exactly do you believe the following answer does not respond to the question?Their answer including a description of the issue and interpretation of the standard was as follows:

The command substitution is a red herring; it's relevant only in that it pointed out where the bug was.

The delimiter to the here-document is quoted, so the lines are not expanded. In this case, the shell reads lines from the input as if they were quoted. If a backslash appears in a context where it is quoted, it does not act as an escape character (see below), and the special handling of backslash-newline does not take place. In fact, if any part of the delimiter is quoted, the here-document lines are read as if single-quoted.

The text in Posix 2.2.1 is written awkwardly, but means that the backslash is only treated specially when it's not quoted. You can quote a backslash and inhibit all all expansion only with single quotes or another backslash.

The close reading part is the "not expanded" text implying the single quotes. The standard says in 2.2 that here documents are "another form of quoting," but the only form of quoting in which words are not expanded at all is single quotes. So it's a form of quoting that is just about exactly like single quotes, but not single quotes.

http://lists.gnu.org/archive/html/bug-bash/2017-02/msg00073.html

@MichaelMrozek The previous answer did not link to a thread started by the asker. The asker asked a mailing list question and the answer was that it was a bug. The asker did not follow-up on that mailing list discussion. I posted a new mailing list thread last night to follow-up with the Bash maintainer, and he responded with exactly an answer to this question. How exactly do you believe the following answer does not respond to the question?

The command substitution is a red herring; it's relevant only in that it pointed out where the bug was.

The delimiter to the here-document is quoted, so the lines are not expanded. In this case, the shell reads lines from the input as if they were quoted. If a backslash appears in a context where it is quoted, it does not act as an escape character (see below), and the special handling of backslash-newline does not take place. In fact, if any part of the delimiter is quoted, the here-document lines are read as if single-quoted.

The text in Posix 2.2.1 is written awkwardly, but means that the backslash is only treated specially when it's not quoted. You can quote a backslash and inhibit all all expansion only with single quotes or another backslash.

The close reading part is the "not expanded" text implying the single quotes. The standard says in 2.2 that here documents are "another form of quoting," but the only form of quoting in which words are not expanded at all is single quotes. So it's a form of quoting that is just about exactly like single quotes, but not single quotes.

http://lists.gnu.org/archive/html/bug-bash/2017-02/msg00073.html

This was asked on Bash's mailing list, and the maintainer confirmed it was a bug

They also mentioned that the text in POSIX "is not necessarily ambiguous, but it does require close reading.", so I asked for a clarification on that. Their answer including a description of the issue and interpretation of the standard was as follows:

The command substitution is a red herring; it's relevant only in that it pointed out where the bug was.

The delimiter to the here-document is quoted, so the lines are not expanded. In this case, the shell reads lines from the input as if they were quoted. If a backslash appears in a context where it is quoted, it does not act as an escape character (see below), and the special handling of backslash-newline does not take place. In fact, if any part of the delimiter is quoted, the here-document lines are read as if single-quoted.

The text in Posix 2.2.1 is written awkwardly, but means that the backslash is only treated specially when it's not quoted. You can quote a backslash and inhibit all all expansion only with single quotes or another backslash.

The close reading part is the "not expanded" text implying the single quotes. The standard says in 2.2 that here documents are "another form of quoting," but the only form of quoting in which words are not expanded at all is single quotes. So it's a form of quoting that is just about exactly like single quotes, but not single quotes.

Source Link
Kevin
  • 421
  • 1
  • 3
  • 9

@MichaelMrozek The previous answer did not link to a thread started by the asker. The asker asked a mailing list question and the answer was that it was a bug. The asker did not follow-up on that mailing list discussion. I posted a new mailing list thread last night to follow-up with the Bash maintainer, and he responded with exactly an answer to this question. How exactly do you believe the following answer does not respond to the question?

The command substitution is a red herring; it's relevant only in that it pointed out where the bug was.

The delimiter to the here-document is quoted, so the lines are not expanded. In this case, the shell reads lines from the input as if they were quoted. If a backslash appears in a context where it is quoted, it does not act as an escape character (see below), and the special handling of backslash-newline does not take place. In fact, if any part of the delimiter is quoted, the here-document lines are read as if single-quoted.

The text in Posix 2.2.1 is written awkwardly, but means that the backslash is only treated specially when it's not quoted. You can quote a backslash and inhibit all all expansion only with single quotes or another backslash.

The close reading part is the "not expanded" text implying the single quotes. The standard says in 2.2 that here documents are "another form of quoting," but the only form of quoting in which words are not expanded at all is single quotes. So it's a form of quoting that is just about exactly like single quotes, but not single quotes.

http://lists.gnu.org/archive/html/bug-bash/2017-02/msg00073.html