bug-bash
[Top][All Lists]
Advanced

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

here-documents in $(command) substitution


From: Alexey Tourbin
Subject: here-documents in $(command) substitution
Date: Sun, 27 Nov 2016 13:12:40 +0300

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-alt-linux-gnu'
-DCONF_VENDOR='alt' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -pipe
-march=native -Wall -g -O2 -Wno-parentheses -Wno-format-security
uname output: Linux celery 4.1.17-std-def-alt1 #1 SMP Tue Feb 2
12:43:38 UTC 2016 x86_64 GNU/Linux
Machine Type: x86_64-alt-linux-gnu

Bash Version: 4.4
Patch Level: 0
Release Status: release

Description:
Handling of here-documents in command substitution seems to be inconsistent.

$ cat test.sh
export foo=$(cat <<EOF
echo bar
EOF)
echo baz

$ bash test.sh
test.sh: line 6: warning: here-document at line 4 delimited by
end-of-file (wanted `EOF')
baz

I see only two possibilities:
1) here-document is ended with the "EOF)" line, which also closes
command substitution; then, bash should't have produced the warning;
2) here-document is not ended with the "EOF)" line and, indeed, spans
to the end of file; then, bash shouldn't have executed the line which
reads "echo baz". But it does both.

In bash-3.2, it used to work without a warning:

$ bash-3.2 test.sh
baz

In bash-4.2, the warning is already there:

$ ./bash-4.2 test.sh
test.sh: line 6: warning: here-document at line 4 delimited by
end-of-file (wanted `EOF')
baz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]