toddbluhm / env-cmd

Setting environment variables from a file
https://www.npmjs.com/package/env-cmd
MIT License
1.73k stars 65 forks source link

echo $FOO not working (even with -x --use-shell) #336

Open yatharth opened 2 years ago

yatharth commented 2 years ago

npx env-cmd -x --use-shell 'echo $FOO' doesn’t seem to be working, even with version 10.1.0 which added support for -x.

image

Based on https://github.com/toddbluhm/env-cmd/issues/93#issuecomment-583985970, I would have expected it to work.

yatharth commented 2 years ago

Even the official example in the README doesn’t work.

Create hello.js with contents:

console.log(process.argv)

Create .env with contents:

FOO=foo

Then run npx env-cmd -x node hello.js.

Result:

image

It appears some attempt at substitution is being made, either by npm or by env-cmd.

jethrolarson commented 2 years ago

I'm running into this as well. @yatharth you haven't found a workaround, have you?