3 ms·
Several people, including you, are proposing using env rather than sourcing; is that somehow preferable to something like this? (. .env; my-cmd)
by malicka 2y ago
Several people, including you, are proposing using env rather than sourcing; is that somehow preferable to something like this?
(. .env; my-cmd)
- colimbarna 2y agoSee my comment sibling to yours for some concerns with `env $(cat file)`; I would have these and then some with sourcing the file even in a subshell. You can do whatever you want in a shell script which can have effects outside of the subshell. Another advantage of env is that you can type `man env` and learn something useful; sourcing and subshells via syntax is a little bit harder. Finally, I think the major point of this branch of the discussion is to explicitly decorate a command with a special environment. Starting up a subshell isn't the same thing. It might have the same effect, but you can see that you're creating a subshell, running a builtin in the subshell, and then running a command in the subshell. It is something of a difference between declarative (dotenv/env) and imperative (sourcing in a subshell) approaches, and inherits all the pros and cons of the imperative approach. If it works for you, I make no recommendation against it.