bug-bash
[Top][All Lists]
Advanced

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

Re: declare(1) not executing inside source'd script


From: Greg Wooledge
Subject: Re: declare(1) not executing inside source'd script
Date: Fri, 27 Jul 2018 10:17:01 -0400
User-agent: NeoMutt/20170113 (1.7.2)

On Fri, Jul 27, 2018 at 12:26:06AM -0400, address@hidden wrote:
> Repeat-By:
>       $ cat <<__EOF__ >/tmp/bashbug.bash
>       > function myfunc {
>       >     echo "Running..."
>       > }
>       > declare -fx myfunc
>       > declare -p -F | grep "myfunc"
>       > __EOF__
>       $ source /tmp/bashbug.bash
> 
>       The function is now defined, but is not exported.
>       And the output of the last command never appears,
>       but if the same command is executed now -- at
>       the interactive shell prompt -- it does show that
>       'myfunc' is defined.

I cannot reproduce this, either in Debian's bash 4.4, or in bash 5.0-alpha.

wooledg:~$ exec bash-5.0-alpha
wooledg:~$ cat foo
function myfunc {
  echo "Running"
}
declare -fx myfunc
declare -p -F | grep myfunc
wooledg:~$ source ./foo
declare -fx myfunc
wooledg:~$ bash -c myfunc
Running

On my system, I see the output from "declare -p -F" upon sourcing the
file, and the function is definitely exported.  I get the same results
using Debian's bash 4.4(.12) as well.



reply via email to

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