How to source a dotenv (.env) file in dash?

Viewed 3309

There are a lot of examples here how to source a dotenv file in bash but has anyone one a method that achieves the same with dash (which is the default shell for minimal Debian installations)?

The solution should look like this:

$ some foo my-command-using-env-vars

e.g.

$ env $(cat .env) my-command-using-env-vars

And it is important that the solution supports multiline values with spaces like:

SSH_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nfoo\nbar\baz"

and special characters like hash within quotes:

SPECIAL="foo#bar"
1 Answers
Related