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: Frank Edwards
Subject: Re: declare(1) not executing inside source'd script
Date: Fri, 27 Jul 2018 12:42:31 -0400

Thanks for your help; I found the problem.

It was a directory in my PATH that included another copy of the script by the 
same name.  I should have been using ./script_name when passing it to the 
source command.  I found this by placing set -x inside the script to see what 
was going on and it never ran.  The which command didn’t help, but whereis 
tracked down the duplicate.

Thanks again for your time (this was embarrassing, as I know better :)).

 <http://www.eeconsulting.net/> 
Edwards & Edwards Consulting, LLC <http://www.eeconsulting.net/>
Frank J. Edwards
address@hidden
Voice: +1 813.406.0604 (rings both office and mobile)


> On Jul 27, 2018, at 11:28 AM, Frank <address@hidden> wrote:
> 
> Hm.  Strange.  I will examine the environment for weirdness regarding 
> BASH_ENV or anything else that might be an issue.  Given that it happens for 
> me in both the stock bash 4.2.46 and the locally built 4.4 (on CentOS 7.4), 
> there must be something common to both and thus external to the shell itself.
> 
> I have installed bashdb on this system as well, but I don’t expect that to 
> have affected anything since it’s an add on that Bash shouldn’t have noticed 
> without the use of --debugger.
> 
> Thanks for your help.
> 
> PS:  So the official line is to not specify the man section for builtins to 
> the shell?  I will not use section numbers in the future. :)
> --
> Frank Edwards
> Edwards & Edwards Consulting, LLC
> Hours:  10A-6P ET
> Phone:  (813) 406-0604
> 
> Sent from my iPhone.  No electrons were harmed in the creation or 
> transmission of this message.
> 
>> On Jul 27, 2018, at 10:17 AM, Greg Wooledge <address@hidden> wrote:
>> 
>>> 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]