option 1:
A bit python specific but you can use python-dotenv[1] for Python; and `source` that file in bash for shell support.
option 2:
Alternatively you could just pass environmental variables between applications (that's kind of the point of them).
option 3:
You could still use a dot env file and import that in other languages as TOML. This is a really nasty hacky way of doing things though because you'd need to read that file in, then prefix a key at the start of the file (eg "[vars]") to adhere to the TOML standard before you could run it through a TOML parser. I wouldn't personally recommend this approach but it would work as a lazy solution.
2) Sure there is, `envsubst`[2]
hello.tmpl:
This is an exmaple
Hello, ${HELLO_NAME}!
hello.env: HELLO_NAME="wodenokoto"
hello.sh: #!/bin/sh
source hello.env
envsubst < hello.tmpl > hello.txt
Run hello.sh and it will create a file called hello.txt: This is an exmaple
Hello, wodenokoto!
One caveat is that this is part of the gettext package which doesn't always ship with every distro. But it's a pretty small package (small enough that I don't have any issue installing it into a docker container for one CI pipeline).That would require me to 1) somehow ensure that shell is sourcing the the environment variables from a file, and 2) we are back to all the hackery mentioned in the article [1]
Also that was just one of three options I listed; and there will be a plethora of other alternatives I've not mentioned too.
You’ve given me a lot of food for thought and some good ideas on how to attack some of my problems.
And for point 2, basically the same thing, you can set variables to have a default value and then try to read the environment.
export variable=${variable:-“some_default”}
1) No good way to store config values, nor ones that can be shared with other languages. I might have a set of python applications running in the cloud and a shell script to deploy them, and guess what, I'd like them to share the same config, so I don't have to keep to update resource names in 2 places.
2) No simple way of templating files. A script that would replace {var} with value of $var in a file seems like an obvious thing for shell to do for you, but I haven't found a good way of doing it.