Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Denis McKeon Newsgroups: gnu.bash.bug Subject: closing '}' misplaced in here-document in function Date: Sat, 29 Jun 2019 10:44:25 -0700 Lines: 68 Approved: bug-bash@gnu.org Message-ID: References: <974cfa51-f126-b373-f471-374a4b695e4a@swcp.com> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1561830549 20744 209.51.188.17 (29 Jun 2019 17:49:09 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org Received-SPF: pass (ame7.swcp.com: authenticated connection) receiver=ame7.swcp.com; client-ip=108.248.120.45; helo=[IPv6:::1]; envelope-from=dmckeon@swcp.com; x-software=spfmilter 2.001 http://www.acme.com/software/spfmilter/ with libspf2-1.2.10; X-Authentication-Warning: ame7.swcp.com: Host 108-248-120-45.lightspeed.sntcca.sbcglobal.net [108.248.120.45] claimed to be [IPv6:::1] User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 Content-Language: en-US X-Scanned-By: MIMEDefang 2.83 X-Virus-Scanned: clamav-milter 0.100.2 at ame7 X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 216.184.2.9 X-Mailman-Approved-At: Sat, 29 Jun 2019 13:49:03 -0400 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <974cfa51-f126-b373-f471-374a4b695e4a@swcp.com> Xref: csiph.com gnu.bash.bug:15072 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<