Use the "dot space script" calling syntax. For example, here's how to do it using the full path to a script:

. /path/to/set_env_vars.sh

These execute the script under the current shell instead of loading another one (which is what would happen if you did ./set_env_vars.sh). Because it runs in the same shell, the environmental variables you set will be available when it exits.


This is the same thing as calling source set_env_vars.sh, but it's shorter to type and might work in some places where source doesn't.

 source set_env_vars.sh



Reference

https://stackoverflow.com/questions/496702/can-a-shell-script-set-environment-variables-of-the-calling-shell

  • No labels