1

For illustration, here is a very basic Javascript file, reduced to the bare essentials, let's say "test.js":

console.log(process.argv.slice(2));

So this line should only output my command line arguments. That's it - no magic at all until here. :)

Now I call this file with Node.js as follows ... and I get:

$ node test --my-path '/my_path'
[
  '--my-path',
  'C:/Users/drundanibel/AppData/Local/Atlassian/SourceTree/git_local/my_path'
]

As you can see, Node simply prefixes my local Windows Git path to the passed string "/my_path".

Can anyone tell me why, and how I can stop it?

Needless to say, in my real code I use a wrapper library (minimist) to parse process.argv.

But of course this doesn't help me if that core property is parsed and changed by Node itself at the earliest possible moment. Even before I have any chance to pick up my original string ...

Edit:

Just now I see that it doesn't seem to be a Node.js-specific problem, but one of the bash I use under Windows. Because if I place the call in the Windows console, the script responds as expected:

> node test --my-path "/my_path"
[ '--my-path', '/my_path' ]
Drunda Nibel
  • 101
  • 6

1 Answers1

1

I found the answer myself in this post:

How to stop MinGW and MSYS from mangling path names given at the command line

Many thanks to @Igor Mukhin!

Drunda Nibel
  • 101
  • 6