Path: csiph.com!goblin3!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: frank@eec.com Newsgroups: gnu.bash.bug Subject: declare(1) not executing inside source'd script Date: Fri, 27 Jul 2018 00:26:06 -0400 (EDT) Lines: 43 Approved: bug-bash@gnu.org Message-ID: NNTP-Posting-Host: lists.gnu.org X-Trace: usenet.stanford.edu 1532699927 3823 208.118.235.17 (27 Jul 2018 13:58:47 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org X-detected-operating-system: by eggs.gnu.org: Mac OS X [generic] [fuzzy] X-Received-From: 65.32.113.132 X-Mailman-Approved-At: Fri, 27 Jul 2018 09:58:44 -0400 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14405 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?!