I'm trying to use node
to do a small inline string manipulation of the current PATH in a bash script (in mintty.exe
on a GitHub Windows Action Runner), but it's not working as expected.
I've recreated the issue in an MSYS2 terminal on my desktop where it was easier to cut it down to the simplest example.
If I run echo $PATH
, I get the /c/...:...
paths I expect (unix like. forward slashes, colons):
camer@QUASAR MINGW64 ~
$ echo $PATH
/c/...:/...
If mix another string in, all works as expected, too:
camer@QUASAR MINGW64 ~
$ echo "console.log('$PATH')"
console.log('/c/...:/...')
But when I put that string as a -e
option to node, it reverts to Windows style paths. Note this doesn't actually run because the backslashes mess up Node's interpretation of the string. It errors on the first \u
which it thinks is the start of a unicode character. This, among other reasons, confirm the incorrect $PATH format.
camer@QUASAR MINGW64 ~
$ node -e "console.log('$PATH')"
[eval]:1
console.log('C:\...')
I cannot for the life of me figure out why...
Even if I wrap the output of a known working echo ...
in node -e "..."
, it messes it up.