New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escaping paths on windows #1

Closed
maxogden opened this Issue Jul 29, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@maxogden

maxogden commented Jul 29, 2014

when I run this on windows:

var spawn = require('execspawn')
spawn(process.execPath + ' -v')

I get this on stderr:

'C:\Program' is not recognized as an internal or external command.

but if I wrap the execPath in quotes, like this:

spawn('"' + process.execPath + '" -v')

then it works.

In the interest of making portable code easier to write, is this something that execspawn should/could try and handle for me or is it outside of scope?

@AndreasMadsen

This comment has been minimized.

Show comment
Hide comment
@AndreasMadsen

AndreasMadsen Jul 29, 2014

Owner

Interresting question. I will say it is outside the scope for the following reasons:

It is not a portability issue:

This will also be an issue on unix like systems. Consider the following setup:

/
|- a b/
   |- b -- #!/bin/sh \n echo "b file"
  • Executing /a b/b -v will fail
  • Executing "/a b/b" -v will output b file

The new behaviour would be difficult to reason about:

Consider the following setup:

/
|- a -- #!/bin/sh \n echo "a file"
|- a b/
   |- b -- #!/bin/sh \n echo "b file"
  • Executing /a b/b -v will output a file
  • Executing "/a b/b" -v will output b file

What should the new expected behaviour be in this case and how can one get the other result?

The behaviour would differ from require('child_process').exec:

https://github.com/joyent/node/blob/master/lib/child_process.js#L618-L619

Owner

AndreasMadsen commented Jul 29, 2014

Interresting question. I will say it is outside the scope for the following reasons:

It is not a portability issue:

This will also be an issue on unix like systems. Consider the following setup:

/
|- a b/
   |- b -- #!/bin/sh \n echo "b file"
  • Executing /a b/b -v will fail
  • Executing "/a b/b" -v will output b file

The new behaviour would be difficult to reason about:

Consider the following setup:

/
|- a -- #!/bin/sh \n echo "a file"
|- a b/
   |- b -- #!/bin/sh \n echo "b file"
  • Executing /a b/b -v will output a file
  • Executing "/a b/b" -v will output b file

What should the new expected behaviour be in this case and how can one get the other result?

The behaviour would differ from require('child_process').exec:

https://github.com/joyent/node/blob/master/lib/child_process.js#L618-L619

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment