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

Inconsistent variable expansion in arguments Win VS Linux #343

Open b12k opened 2 years ago

b12k commented 2 years ago

Hello, thank you for a great lib 🤘

I'm facing a problem related to environment variables expansion on Windows and Linux (Github Actions)

I use env-cmd in package.json scripts.

.env

VAR=Hello World

package.json

{
  "name": "env-cmd-bug",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "unescaped": "env-cmd -x --verbose echo $VAR",
    "escaped": "env-cmd -x --verbose echo \\$VAR"
  },
  "dependencies": {
    "env-cmd": "^10.1.0"
  }
}

Escaping the $ sign works for Linux, but fails on Windows.

Outputs:

Ubuntu изображение

Windows изображение