Reputation: 295
I have a shell script that needs changing so as to only work when the value of an environment variable is true
. The variable will come from Heroku, if that matters.
My script looks like:
if [[ $SANDBOX_SITE = "true" ]]
then
*run existing script*
else
exit
fi
I can see the environment variable is present with printenv
and I run the script through heroku run bash --app *appname*
so I know it's in the right shell.
Any tips or advice would be appreciated.
*edit
I forgot to add, the script exits everytime.
Upvotes: -1
Views: 3244
Reputation: 7469
I've never used Heroku but a quick glance at the documentation implies you need to explicitly set the desired env vars. For example, heroku run bash --env SANDBOX_SITE=$SANDBOX_SITE --app appname
. Or, possibly via the heroku config:set
command.
See https://devcenter.heroku.com/articles/heroku-cli-commands#heroku-run
Upvotes: 0
Reputation: 1233
You may have forgotten to export the environment variable. The environment variable may exist in current shell, but won't be available to child shell if it is not exported. Use:
export SANDBOX_SITE="true"
Upvotes: 5