bug-bash
[Top][All Lists]
Advanced

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

An exported function is malformed if it contains a nested function defin


From: Sherwood Wang
Subject: An exported function is malformed if it contains a nested function definition with heredoc
Date: Fri, 06 Mar 2020 22:48:05 +0800
User-agent: Evolution 3.30.5-1.1

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'




reply via email to

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