In most POSIX‐style shells (bash, zsh, etc.), including the ones you’ll find on macOS, set can be used to turn various shell options on or off.
set -a
This turns on the allexport option (same as set -o allexport). From that point on, every variable you assign is automatically exported into the environment.
$ set -a$ FOO=bar # automatically exported$ export -p # you’ll see FOO in the list of exported varsset +a
This turns allexport back off (same as set +o allexport). Variables you assign after this will not be exported unless you explicitly use export.
xxxxxxxxxx$ set +a$ BAZ=qux # not exported$ export -p # BAZ won’t be in the exported listA common use-case is when you have a plain text file of variable assignments:
xxxxxxxxxxset -asource my-env-file.shset +aThat way everything defined in my-env-file.sh ends up in your environment without having to prefix each line with export.