#486906 bash: \<newline> handling in here-documents might be broken

Package:
bash
Source:
bash
Description:
GNU Bourne Again SHell
Submitter:
Jörg Sommer
Date:
2024-04-07 12:15:09 UTC
Severity:
normal
#486906#5
Date:
2008-06-18 20:08:48 UTC
From:
To:
Hi,

I've this script:
#!/bin/sh

cat <<__EOF
$(/bin/echo 'aa\\
b')
__EOF

cat <<__EOF
$(/bin/echo 'aa\
b')
__EOF

\<newline> is removed, but two backslahes aren't replaced by one, as I
expect it would happen is the backslash would be expanded.

% bash /tmp/skript
aa\\
b
aab
% dash /tmp/skript
aa\\
b
aa\
b
% zsh /tmp/skript
aa\\
b
aa\
b

And yes, the section 2.7.4 of the POSIX standard is somewhat unclear.

  If no characters in word are quoted, all lines of the here-document
  shall be expanded for parameter expansion, command substitution, and
  arithmetic expansion. In this case, the backslash in the input behaves
  as the backslash inside double-quotes (see Double-Quotes). However, the
  double-quote character ( ' )' shall not be treated specially within a
  here-document, except when the double-quote appears within "$()", "``",
  or "${}".

Bye, Jörg.