I have a file with some $VARIABLES which I want to substitute using envsubst tool. But in my case the tool is substituting only +/- half of the variables.
To illustrate: I have a file .env with some variables:
MODE=HTTP
URL=https://some.url:0000/xyz
I use
$ source .env
And now, when both of the variables are set only MODE is correctly used by envsubst
echo $MODE
HTTP
echo 'mode: $MODE' | envsubst
mode: HTTP
echo $URL
https://some.url:0000/xyz
echo 'url: $URL' | envsubst
url:
Any ideas why envsubst not working for all variables?
I guess that it's only working for
$MODEby accident - because you have an exported$MODEvariable in your shell.In order for
envsubstto work it needs to inherit the environment variables from your shell which is only done forexported variables.It'll work if your
.envfile exports the variables: