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.sh
orsource set_env_lin.sh
) rather than simply run – steeldriver Jun 22 '22 at 21:59./set_env_lin.sh
,bash
creates a process, sets up redirections, and startsbash
in 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 mustsource
the file.source
interprets 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