node icon indicating copy to clipboard operation
node copied to clipboard

[--env-file] Space between = and " will cause the value to be parsed as an unquoted string

Open panzi opened this issue 8 months ago • 11 comments

Meaning if you have this in your .env file:

FOO= "BAR"

This command:

node --env-file=.env -e 'console.log({ FOO: process.env.FOO })'

Will print this:

{ FOO: '"BAR"' }

I.e. the variable value includes the quotes. (The spaces aren't included in the value, though.) I think this is unexpected.

If this is not intentional there needs to be white space skipping before this line:

https://github.com/nodejs/node/blob/9495a2bf1f20f853e90c8208741ad53448df986a/src/node_dotenv.cc#L153

panzi avatar Jun 15 '24 01:06 panzi