Skip to content
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

doc: script with space spawn example for windows #8035

Closed
wants to merge 1 commit into from

Conversation

bzoz
Copy link
Contributor

@bzoz bzoz commented Aug 9, 2016

Checklist
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

doc

Description of change

Adds an example of how to spawn a shell script under Windows with spaces in its filename.

Ref: #7367

cc @nodejs/documentation

Adds an example of how to spawn a shell script under Windows with
spaces in its filename.

Ref: nodejs#7367
@nodejs-github-bot nodejs-github-bot added child_process Issues and PRs related to the child_process subsystem. doc Issues and PRs related to the documentations. labels Aug 9, 2016
@eljefedelrodeodeljefe
Copy link
Contributor

-1. This is basic escaping on Windows. Imo, anyone targeting the platform knows this.

@eljefedelrodeodeljefe
Copy link
Contributor

@addaleax ?

@addaleax
Copy link
Member

addaleax commented Aug 9, 2016

@eljefedelrodeodeljefe Yeah, was just replying… ;) I would say that I am a counterexample myself… Windows cmd escaping rules seem weird to me, and any Windows testing I do comes for me at a kinda high cost (a very slow VM or AppVeyor are basically my choices). At the same time, I can’t avoid targeting Windows with e.g. npm modules I’m working on, because there is a general assumption that Node.js modules work in a more or less cross-platform way.

@addaleax
Copy link
Member

addaleax commented Aug 9, 2016

In any case, 8 lines in the docs don’t seem like an unreasonably high cost for helping to explain something that comes up on the issue tracker here every few months (if I’m thinking of the right kind of issues)…

@addaleax addaleax added the windows Issues and PRs related to the Windows platform. label Aug 9, 2016
@eljefedelrodeodeljefe
Copy link
Contributor

Yeah. Fair point. No strong opinion, still I don't see the need. Wouldn't mind if this goes forward.

// Script with spaces in the filename:
const bat = spawn('"my script.cmd"', ['a', 'b'], { shell:true });
// or:
exec('"my script.cmd" a b', (err, stdout, stderr) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just for my own understading… these two variants won’t be distinguishable, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, they won't. Final Winapi call will have the same parameter (something like cmd.exe /s /k ""my script.cmd" a b")

@joaocgreis
Copy link
Member

I agree with @addaleax , this provides some help with very little cost. The referenced issue proves that this is not obvious for some users.

LGTM

@bzoz
Copy link
Contributor Author

bzoz commented Aug 12, 2016

@nodejs/documentation @nodejs/platform-windows any suggestions?

I'll land this next week if there are no objections.

@jasnell
Copy link
Member

jasnell commented Aug 12, 2016

LGTM. In my view, more examples are almost always a good thing and we have had questions on this before.

@addaleax
Copy link
Member

Btw, if we want to be more careful about not overloading the documentation pages with unnecessary examples or notes, we can always start using the HTML5 <details> tag to reduce that. Don’t think that’s necessary in this case, though.

jasnell pushed a commit that referenced this pull request Aug 18, 2016
Adds an example of how to spawn a shell script under Windows with
spaces in its filename.

Ref: #7367
PR-URL: #8035
Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell
Copy link
Member

jasnell commented Aug 18, 2016

@bzoz ... I went ahead and landed this in 0abdf59.

@jasnell jasnell closed this Aug 18, 2016
evanlucas pushed a commit that referenced this pull request Aug 24, 2016
Adds an example of how to spawn a shell script under Windows with
spaces in its filename.

Ref: #7367
PR-URL: #8035
Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem. doc Issues and PRs related to the documentations. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants