0

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?

HuLu ViCa
  • 137

1 Answers1

2

When you ./set_env_lin.sh, bash creates a process, sets up redirections, and starts /bin/bash 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 its environment (with your changes) is discarded. Like @steeldriver: says, you must source 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
  • 37,856