I am trying to set environment variables from Bash as follow bash -c 'export FOO=BAR'
but when I try to read the previously set variable using echo $FOO
or bash -c 'echo $FOO'
I can see that the variable is not initialized and the command returns an empty line.
How would I be able to set an environment variable from a command line using Bash to make it accessible from the same shell that started the program (i.e. bash -c 'export FOO=BAR'
) in a first place ?
FOO=BAR
to make it available as a shell variable in the "main" shell instance, orexport FOO=BAR
to make it available in that shell and in the environment of processes started from it. I'm not exactly at all sure why you'd run another shell here?export SECRET_NAME=SECRET_VALUE
so that the container can rus the commandbash -c 'source /path/to/file' && npm start
and. Yet none of the secrets I set in this script are available in any shell I start on the container later on.bash -c 'source /path/to/file' && npm start'
the env vars set by the sourced script should be available tonpm
there. But there's no "global" environment where env vars would be set: they're only inherited to child processes, not to the parent, to to siblings.npm start
usingprocess.env.VAR_NAME
, the variable isundefined
. I am very confused that this does not work given that I am doing the very same thing described in this example: vaultproject.io/docs/platform/k8s/injector/…