[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
declare(1) not executing inside source'd script
From: |
sales |
Subject: |
declare(1) not executing inside source'd script |
Date: |
Fri, 27 Jul 2018 00:26:51 -0400 (EDT) |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu'
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_GNU_SOURCE -DRECYCLES_PIDS
-DDEFAULT_PATH_VALUE='/usr/local/bin:/usr/bin' -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic
-Wno-parentheses -Wno-format-security
uname output: Linux student.eeconsulting.net 3.10.0-693.11.6.el7.x86_64 #1 SMP
Thu Jan 4 01:06:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-redhat-linux-gnu
Bash Version: 4.4
Patch Level: 23
Release Status: release
Description:
A script contains a function definition followed by
declare -fx funcname
but the declare(1) doesn't execute and the function
is not exported after source'ing the file. In addition,
executing 'declare -p -F | grep "funcname"' does not
produce any output (making me think that declare(1)
isn't being executed at all).
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.
Fix:
Strangely, if I create another script that sources
the first one, then execute the declare commands in
that second script, everything works when I source
the second file?!
- declare(1) not executing inside source'd script,
sales <=