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: fixes default shell in child_process.md #14203

Closed
wants to merge 7 commits into from

Conversation

henryzxu
Copy link
Contributor

This PR clarifies that 'process.env.ComSpec' is the default shell in
Windows and that 'cmd.exe' is only used as a fallback.

Fixes: #14156

Checklist
Affected core subsystem(s)

doc

Clarifies the default shell in Windows is process.env.ComSpec
and that cmd.exe is only used as a fallback. Functions whose
descriptions are affected include:
child_process.spawn, child_process.exec,
child_process.spawnsSync, and child_process.execSync.

Fixes: nodejs#14156
@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 Jul 12, 2017
Clarifies that the default shell in Windows is process.env.ComSpec
and that cmd.exe is only used as a fallback. Functions whose
descriptions are affected include:
child_process.spawn, child_process.exec,
child_process.spawnSync, and child_process.execSync.

Fixes: nodejs#14156
@vsemozhetbyt
Copy link
Contributor

Thank you!

A nit: the length of some new lines is more than 80 chars now. Can you rewrap them according to our style guide?

Rewrapped lines over 80 characters according to the Style Guide.
@henryzxu
Copy link
Contributor Author

No problem! I rewrapped the lines in my latest commit.

Thanks for the feedback!

Copy link
Member

@tniessen tniessen left a comment

Choose a reason for hiding this comment

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

I am kind of unsatisfied with having the same content four times, even though it is not too long... Still not pretty IMO.

@henryzxu
Copy link
Contributor Author

Would a footnote be more appropriate in this situation?

@tniessen
Copy link
Member

I would prefer that, maybe a small section at the bottom of the page (similar to this section)? Let's wait for another opinion on this :)

@henryzxu
Copy link
Contributor Author

I'll see what I can do once we get another opinion! I do like how much cleaner that solution is compared to my current commit.

@tniessen
Copy link
Member

@nodejs/documentation opionions regarding the current state vs. a footnote / paragraph at the bottom?

@benjamingr
Copy link
Member

+1 for footnote - I think adding too much text to parameter definitions can be really confusing.

@tniessen tniessen self-assigned this Jul 16, 2017
Reorganizes `child_process` shell spawning information.

Fixes: nodejs#14156
@henryzxu
Copy link
Contributor Author

I split the shell spawn information into two sections at the bottom, Shell Requirements and Default Windows Shell. I was having a bit of trouble combining the information into one section logically, so if you have any suggestions, let me know!

to `false` (no shell).
`'/bin/sh'` on UNIX, and `'process.env.ComSpec'` on Windows. See
[Shell Requirements][] and [Default Windows Shell][]. A different shell can
be specified as a string. Defaults to `false` (no shell).
Copy link
Member

Choose a reason for hiding this comment

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

Any reason why you swapped the last two sentences compared to spawn?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh oops! That was an accident. It should be fixed in the latest commit.

@@ -1303,6 +1314,8 @@ to `stdout` although there are only 4 characters.
[`child_process.spawn()`]: #child_process_child_process_spawn_command_args_options
[`child_process.spawnSync()`]: #child_process_child_process_spawnsync_command_args_options
[`maxBuffer` and Unicode]: #child_process_maxbuffer_and_unicode
[Shell Requirements]: #child_process_shell_requirements
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Jul 17, 2017

Choose a reason for hiding this comment

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

This and the next references are out of ASCII sort order (should be placed before the last reference).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the heads up! They should be in the correct order in the latest commit.

Small formatting fixes for shell spawning information.

Fixes: nodejs#14156
@henryzxu
Copy link
Contributor Author

The latest commit should be updated with your reviews. Let me know if you have any more comments or suggestions! Thanks for making my first pull request a very enjoyable experience!

Copy link
Member

@tniessen tniessen left a comment

Choose a reason for hiding this comment

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

Thank you for your efforts! 😃 I added some final nits but everything else looks great!

Don't worry, it is completely normal that non-trivial changes need to be reviewed and adapted several times. This is our way to maintain and improve the quality of our project :)

(Default: `'/bin/sh'` on UNIX, `'cmd.exe'` on Windows, The shell should
understand the `-c` switch on UNIX or `/d /s /c` on Windows. On Windows,
command line parsing should be compatible with `cmd.exe`.)
(Default: `'/bin/sh'` on UNIX, `'process.env.ComSpec'` on Windows. See
Copy link
Member

Choose a reason for hiding this comment

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

process.env.ComSpec is a property (variable), not a string literal, so it should not be quoted.

`'/bin/sh'` on UNIX, and `'cmd.exe'` on Windows. A different shell can be
specified as a string. The shell should understand the `-c` switch on UNIX,
or `/d /s /c` on Windows. Defaults to `false` (no shell).
`'/bin/sh'` on UNIX, and `'process.env.ComSpec'` on Windows. A different
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

(Default: `'/bin/sh'` on UNIX, `'cmd.exe'` on Windows, The shell should
understand the `-c` switch on UNIX or `/d /s /c` on Windows. On Windows,
command line parsing should be compatible with `cmd.exe`.)
(Default: `'/bin/sh'` on UNIX, `'process.env.ComSpec'` on Windows. See
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

`'/bin/sh'` on UNIX, and `'cmd.exe'` on Windows. A different shell can be
specified as a string. The shell should understand the `-c` switch on UNIX,
or `/d /s /c` on Windows. Defaults to `false` (no shell).
`'/bin/sh'` on UNIX, and `'process.env.ComSpec'` on Windows. A different
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

Although Microsoft specifies `'process.env.ComSpec'` must contain the path to
`'cmd.exe'` in the root environment, child processes are not always subject to
the same requirement. Thus, in `child_process` functions where a shell can be
spawned, `'cmd.exe'` is used as a fallback if `'process.env.ComSpec'` is
Copy link
Member

Choose a reason for hiding this comment

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

See above.


## Default Windows Shell

Although Microsoft specifies `'process.env.ComSpec'` must contain the path to
Copy link
Member

Choose a reason for hiding this comment

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

Microsoft does not specify anything regarding process.env.ComSpec. This is just node's representation of the process environment. Actually, Microsoft only holds that assertion for the environment variable as stored in the registry. The technical background will be too complex for our docs and is not really relevant, but I would prefer %COMSPEC% instead of process.env.ComSpec here (and only here).

Notation changes for `process.env.ComSpec`

Fixes: nodejs#14156
@henryzxu
Copy link
Contributor Author

The references to process.env.ComSpec should all be fixed!

Thank you for all your help! The level of detail you put into your feedback makes me look forward to contributing in the future! 😃

Copy link
Member

@tniessen tniessen left a comment

Choose a reason for hiding this comment

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

Last nit, I swear!


## Default Windows Shell

Although Microsoft specifies `%COMSPEC` must contain the path to
Copy link
Member

@tniessen tniessen Jul 18, 2017

Choose a reason for hiding this comment

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

Environment variables must be enclosed in %s under Windows, so it should be %COMSPEC% (note the % at the end).

Wrapped `%COMSPEC%` with percent signs.

Fixes: nodejs#14156
@henryzxu
Copy link
Contributor Author

Oh oops! It should be fixed now. :)

tniessen pushed a commit that referenced this pull request Jul 20, 2017
Clarifies the default shell in Windows is process.env.ComSpec
and that cmd.exe is only used as a fallback. Functions whose
descriptions are affected include:
child_process.spawn, child_process.exec,
child_process.spawnsSync, and child_process.execSync.

PR-URL: #14203
Fixes: #14156
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
@tniessen
Copy link
Member

Landed in 7fdcb68 🎉 Thank you very much! 😃

A few tips for future contributions:

  1. You might want to disable BOM (byte-order mark) in your editor when working on node, all of our files are encoded as UTF-8 without BOM (that's why GitHub says you changed the first line of the file).
  2. You might also want to check your changes for trailing whitespace (e.g on this line). Even though we can fix these problems while landing PRs, it is a good habit to pay attention to that.
  3. You don't need to use the same commit title for fixups (follow-up commits). Actually, it is usually easier for us to keep track of your commits if you include a summary of the new changes in the commit title. The first commit of the PR should use the format as described in CONTRIBUTING.md though :)

@tniessen tniessen closed this Jul 20, 2017
@henryzxu
Copy link
Contributor Author

Wow, my pull request landing is more exciting than I could've imagined! Thank you so much for all your help! 😃

Thank you also for the helpful tips! They answered a number of questions that I didn't quite know how to ask. :)

I look forward to contributing again soon!

addaleax pushed a commit that referenced this pull request Jul 22, 2017
Clarifies the default shell in Windows is process.env.ComSpec
and that cmd.exe is only used as a fallback. Functions whose
descriptions are affected include:
child_process.spawn, child_process.exec,
child_process.spawnsSync, and child_process.execSync.

PR-URL: #14203
Fixes: #14156
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Fishrock123 pushed a commit that referenced this pull request Jul 24, 2017
Clarifies the default shell in Windows is process.env.ComSpec
and that cmd.exe is only used as a fallback. Functions whose
descriptions are affected include:
child_process.spawn, child_process.exec,
child_process.spawnsSync, and child_process.execSync.

PR-URL: #14203
Fixes: #14156
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
@addaleax addaleax mentioned this pull request Jul 24, 2017
@addaleax addaleax mentioned this pull request Aug 2, 2017
@MylesBorins
Copy link
Contributor

is this accurate for v6.x as well?

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

child_process,Windows: fix docs for spawn({shell})
7 participants