Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15995

An exported function is malformed if it contains a nested function definition with heredoc

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Sherwood Wang <sherwood@wang.onl>
Newsgroups gnu.bash.bug
Subject An exported function is malformed if it contains a nested function definition with heredoc
Date Fri, 06 Mar 2020 22:48:05 +0800
Lines 47
Approved bug-bash@gnu.org
Message-ID <mailman.2177.1583509179.2412.bug-bash@gnu.org> (permalink)
References <3ec210c3a23f1ad8ad73a3093766c934d50fa3f6.camel@wang.onl>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1583509179 12842 209.51.188.17 (6 Mar 2020 15:39:39 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=simple/simple; d=wang.onl; s=1429769701; t=1583506094; bh=LahJ/YI5kZoqN+1dUPSmamAneG08W2xioBAKlDhUHrY=; h=Subject:From:To:Date:From; b=lCdaiVaLmLqv4tSR8h/vkZYDsPNUkfsv+pmdoJiSb6lfosDh5ikZlP/MuV6DT4xnD wyLWcQD7LGahzSeLTb3vJNUJVNYb75l9PXk5O5ehtresS9DqMG2viwesT7E5syWQIu ZqqI7m9S/lDhjp2KUTyArUjawbdrlgvhAaRDLNxc=
User-Agent Evolution 3.30.5-1.1
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy]
X-Received-From 104.238.181.107
X-Mailman-Approved-At Fri, 06 Mar 2020 10:39:37 -0500
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <3ec210c3a23f1ad8ad73a3093766c934d50fa3f6.camel@wang.onl>
Xref csiph.com gnu.bash.bug:15995

Show key headers only | View raw


Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-2bxm7h/bash-
5.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wall
-Wno-parentheses -Wno-format-security
uname output: Linux hostname 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1
(2020-01-26) x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.0
Patch Level: 3
Release Status: release

Description:

	A function containing a nested function definition with heredoc
	cannot be serialized into the environment variable correctly,
	and leads to failures in a subshell.

	See also: 
https://stackoverflow.com/questions/60564674/exporting-a-function-with-a-nested-function-definition-and-heredoc-in-bash

Repeat-By:

	Create a script:

		#!/bin/bash
		
		f() {
		    g() {
		        cat <<EOF
		EOF
		    }
		
		    g
		}
		
		export -f f
		bash -c ':'

	Executing it yields the following error:
		bash: f: line 8: syntax error: unexpected end of file
		bash: error importing function definition for `f'

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

An exported function is malformed if it contains a nested function definition with heredoc Sherwood Wang <sherwood@wang.onl> - 2020-03-06 22:48 +0800

csiph-web