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 339aad08626d 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.0 Patch Level: 3 Release Status: release Description: Sourcing a script with `set -a` at the end fails and an absolute path fails to set variables the first time it is executed. Repeat-By: I ran this in a debian docker container to reduce as many variables as possible. $ docker run -it --rm debian:latest root@339aad08626d:/# adduser --disabled-password -gecos "" bash-test Adding user `bash-test' ... Adding new group `bash-test' (1000) ... Adding new user `bash-test' (1000) with group `bash-test' ... Creating home directory `/home/bash-test' ... Copying files from `/etc/skel' ... root@339aad08626d:/# su -l bash-test bash-test@339aad08626d:~$ echo -e '#!/bin/bash\nFOO=bar\nset -a\nenv | grep FOO' > sourceme bash-test@339aad08626d:~$ . /home/bash-test/sourceme bash-test@339aad08626d:~$ . /home/bash-test/sourceme FOO=bar It reproduces in centos:7 container as well. I did not see it in ancient macOS bash. [root@227f958499c1 /]# adduser bash-test [root@227f958499c1 /]# su -l bash-test [bash-test@227f958499c1 ~]$ echo -e '#!/bin/bash\nFOO=bar\nFOO=bar2\nset -a\nenv | grep FOO' > sourceme [bash-test@227f958499c1 ~]$ cat sourceme #!/bin/bash FOO=bar FOO=bar2 set -a env | grep FOO [bash-test@227f958499c1 ~]$ . /home/bash-test/sourceme [bash-test@227f958499c1 ~]$ . /home/bash-test/sourceme FOO=bar2 It is the same for explicitly using "source": [root@2ff7740a55e9 /]# adduser bash-test [root@2ff7740a55e9 /]# su -l bash-test [bash-test@2ff7740a55e9 ~]$ echo -e '#!/bin/bash\nFOO=bar\nFOO=bar2\nset -a\nenv | grep FOO' > sourceme [bash-test@2ff7740a55e9 ~]$ [bash-test@2ff7740a55e9 ~]$ cat sourceme #!/bin/bash FOO=bar FOO=bar2 set -a env | grep FOO [bash-test@2ff7740a55e9 ~]$ cat sourceme #!/bin/bash FOO=bar FOO=bar2 set -a env | grep FOO [bash-test@2ff7740a55e9 ~]$ source /home/bash-test/sourceme [bash-test@2ff7740a55e9 ~]$ source /home/bash-test/sourceme FOO=bar2