How to pass a literal slash in Node.js in Git Bash for Windows?

I use Git Bash for Windows (as in, I right-click in some directory and select "Git Bash here" from the context menu). Node.js v5.10.1.

Here my script full Node.js, example.js:

console.log(process.argv);

Here is my command line and output:

$ node example.js "https://example.com"
[ 'C:\\...\\node.exe',
  'C:\\...\\example.js',
  'https:\\example.com' ]

Note that the input argument https://example.com "has two literal slashes , but the resulting string" https: \\ example.com "has one backslash literal .

I found that no amount of backslash (for example, https: \\ / example.com) or additional slashes (for example, https: ////////example.com ") on the command line can stop this. Result there is always one literal backslash.

Using the same Node.js executable to run the same script from a regular Windows window cmd.exedoes not cause this behavior. Running the equivalent Python script from Git Bash for Windows also does not cause this behavior.

Update

See this:

$ node.exe -e "console.log(process.argv)" "https://example.com"
[ 'C:\\...\\node.exe',
  'https://example.com' ]

$ node -e "console.log(process.argv)" "https://example.com"
[ 'C:\\...\\node.exe',
  'https:\\example.com' ]

".exe" ? NVM 1.1.0, . which node.exe which node , EXE . node. Node.js 5.10.1, Node.js 6.0.0.

+4
1

Git Bash MSYS2, " POSIX path conversion", MinGW. windows-ifys , . MSYS2, , " Windows" MinGW.

joezen777, , : ;https:;http: MSYS2_ARG_CONV_EXCL. https://github.com/msys2/msys2/wiki/Porting.

0

All Articles