I have the following file, named set_env_lin.sh:
#!/bin/bash
export SLACK_WEBHOOK_DEV=some_value_1
export SLACK_WEBHOOK_REAL=some_value_2
I followed this guide to make it a bash file, but when y call echo $SLACK_WEBHOOK_REAL, I get no value set.
What am I doing wrong?
. set_env_lin.shorsource set_env_lin.sh) rather than simply run – steeldriver Jun 22 '22 at 21:59./set_env_lin.sh,bashcreates a process, sets up redirections, and startsbashin that process to interpret your script. Your script adds the environment variable settings to the process's environment. When your script finishes, the process exits, and it's environment (with your changes) is discarded. Like @steeldriver says, you mustsourcethe file.sourceinterprets the script in the current shell. Once the environment variable changes are added to the current shell, they'll be passed on to processes started by the current shell. – waltinator Jun 22 '22 at 22:52