Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15072 > unrolled thread
| Started by | Denis McKeon <dmckeon@swcp.com> |
|---|---|
| First post | 2019-06-29 10:44 -0700 |
| Last post | 2019-06-29 10:44 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to gnu.bash.bug
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
closing '}' misplaced in here-document in function Denis McKeon <dmckeon@swcp.com> - 2019-06-29 10:44 -0700
| From | Denis McKeon <dmckeon@swcp.com> |
|---|---|
| Date | 2019-06-29 10:44 -0700 |
| Subject | closing '}' misplaced in here-document in function |
| Message-ID | <mailman.1601.1561830548.10840.bug-bash@gnu.org> |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -O2 -g -pipe -Wall -Werror=format-security
-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions
-fstack-protector-strong -grecord-gcc-switches
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
-fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
-Wno-parentheses -Wno-format-security
uname output: Linux dt1 5.1.12-300.fc30.x86_64 #1 SMP Wed Jun 19
15:19:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-redhat-linux-gnu
Bash Version: 5.0
Patch Level: 7
Release Status: release
Description:
Bash appears to move the closing '}'
from after a closing here-document delimiter
to the start of the here-doc body
(just after the opening here-document delimiter)
in a function definition contained within
another function definition.
This conflicts with later invocations of /bin/sh , like:
$ /bin/sh
sh: demo: line 22: syntax error: unexpected end of file
sh: error importing function definition for `demo'
Workaround:
assign the text within the here-doc to a variable.
Repeat-By:
#!/bin/bash
bash --version 2>&1 | head -1
demo () {
# problem
function sub () { cat<<'EOFsub'
sub
EOFsub
} # this brace is moved to just after <<'EOFsub'
# workaround
function var () { local var="$(cat<<'EOFvar'
var
EOFvar
)"
echo "$var"
};
cat<<EOF
demo
EOF
# invoke sub-functions
sub;
var
}
declare -f -x demo
# display function definitions with moved '}'
typeset -f -p demo
# invoke main function
demo
Back to top | Article view | gnu.bash.bug
csiph-web