On Tue, Jul 27, 2021 at 11:42:02PM +0000, Van Klaveren, Brian N. wrote:
> [bash-test@227f958499c1 ~]$ cat sourceme
> #!/bin/bash
> FOO=bar
> FOO=bar2
> set -a
> env | grep FOO

You probably want to put set -a at the top, before the variables are
set.  The -a flag isn't retroactive.  It only applies to variables
that are set *while* it's turned on.

The typical ways that set -a is used are:

1) Around a block of variable assignments within a script, in order to
   avoid having to type "export" several times.

2) Right before sourcing (dotting in) a second file which contains only
   variable assignments, so that all of those variable assignments are
   copied to the environment, without having to modify the sourced file.

Reply via email to