-
Notifications
You must be signed in to change notification settings - Fork 30k
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: improve child_process.execFile() code example #4504
Conversation
@@ -176,8 +176,8 @@ replace the existing process and uses a shell to execute the command.* | |||
|
|||
### child_process.execFile(file[, args][, options][, callback]) | |||
|
|||
* `file` {String} The filename of the program to run | |||
* `args` {Array} List of string arguments | |||
* `file` {String} An absolute path to an executable file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not true, don't know what gives @ryansobol that idea:
> child_process.execFile('date', function(_, stdout){console.log(stdout)});null;
null
> Thu 31 Dec 2015 16:43:59 PST
man pages:
The execlp(), execvp(), and execvpe() functions duplicate the actions of the shell in searching for an executable file if the specified filename does not contain a slash (/) character. The file is sought in the colon-separated list of directory pathnames specified in the PATH environment variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "if there is a slash it won't be looked up in the PATH" is an interesting gotcha, worth mentioning... but would require confirmation that is how it works on windows, too, so the docs can be correct for both systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The subsystem prefix should probably be |
5c7bc12
to
df05b3a
Compare
@sam-github @mscdex: Thanks for the input. I think all your concerns have been addressed. Please let me know if there's anything else that needs tweaking. |
@@ -176,7 +176,7 @@ replace the existing process and uses a shell to execute the command.* | |||
|
|||
### child_process.execFile(file[, args][, options][, callback]) | |||
|
|||
* `file` {String} The filename of the program to run | |||
* `file` {String} A relative or absolute path to an executable file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not right. In my comment I showed the execing "date" works fine, and it not a relative or absolute path. The previous docs are correct, what are you trying to fix?
431233c
to
2db69eb
Compare
@sam-github I see how the explanation of searching the directories inside the I also see how the relative and absolute path description of the |
7219a67
to
21e0253
Compare
LGTM |
[`child_process.exec()`][]. | ||
|
||
The same options as `child_process.exec()` are supported. If a `file` path | ||
contains no slash delimiters, `child_process.execFile()` searches for a matching |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of "slash delimiters", I would say "path separators", "path delimiters", or just "slashes".
From a higher level, this might not be the best place to explain how PATH
lookup works, as it's not specific to execFile()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I suggested mentioning the slash caveat... but I think @cjihrig is right, its not specific to execFile, its just how PATH lookup works, so probably not worth mentioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. I've removed the line.
looks fine to me |
Fixed and rebased |
LGTM. Thanks. |
PR-URL: #4504 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
Landed in d139704 |
PR-URL: #4504 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
The changes to the file argument of execFile in nodejs#4504 make it appear that execFile requires an absolute or relative path to the executable file, when it also supports a filename which will be resolved using $PATH. Although the example makes this clear, assuming there isn't a node binary in $CWD, it's easy to overlook. This commit clarifies that point. It also updates the argument description for execFileSync to match, since it was overlooked in nodejs#4504 and behaves identically. Signed-off-by: Kevin Locke <[email protected]>
The changes to the file argument of execFile in #4504 make it appear that execFile requires an absolute or relative path to the executable file, when it also supports a filename which will be resolved using $PATH. Although the example makes this clear, assuming there isn't a node binary in $CWD, it's easy to overlook. This commit clarifies that point. It also updates the argument description for execFileSync to match, since it was overlooked in #4504 and behaves identically. PR-URL: #5310 Reviewed-By: James M Snell <[email protected]>
The changes to the file argument of execFile in #4504 make it appear that execFile requires an absolute or relative path to the executable file, when it also supports a filename which will be resolved using $PATH. Although the example makes this clear, assuming there isn't a node binary in $CWD, it's easy to overlook. This commit clarifies that point. It also updates the argument description for execFileSync to match, since it was overlooked in #4504 and behaves identically. PR-URL: #5310 Reviewed-By: James M Snell <[email protected]>
PR-URL: #4504 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
The changes to the file argument of execFile in #4504 make it appear that execFile requires an absolute or relative path to the executable file, when it also supports a filename which will be resolved using $PATH. Although the example makes this clear, assuming there isn't a node binary in $CWD, it's easy to overlook. This commit clarifies that point. It also updates the argument description for execFileSync to match, since it was overlooked in #4504 and behaves identically. PR-URL: #5310 Reviewed-By: James M Snell <[email protected]>
PR-URL: #4504 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
The changes to the file argument of execFile in #4504 make it appear that execFile requires an absolute or relative path to the executable file, when it also supports a filename which will be resolved using $PATH. Although the example makes this clear, assuming there isn't a node binary in $CWD, it's easy to overlook. This commit clarifies that point. It also updates the argument description for execFileSync to match, since it was overlooked in #4504 and behaves identically. PR-URL: #5310 Reviewed-By: James M Snell <[email protected]>
PR-URL: #4504 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
The changes to the file argument of execFile in #4504 make it appear that execFile requires an absolute or relative path to the executable file, when it also supports a filename which will be resolved using $PATH. Although the example makes this clear, assuming there isn't a node binary in $CWD, it's easy to overlook. This commit clarifies that point. It also updates the argument description for execFileSync to match, since it was overlooked in #4504 and behaves identically. PR-URL: #5310 Reviewed-By: James M Snell <[email protected]>
PR-URL: nodejs#4504 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
The current code example for
child_process.execFile()
doesn't work even on Unix-like platforms. Since there's no shell wrapper,file
must be a relative or absolute path to executable.args
must contain all the command line arguments forfile
.Here's an alternative I whipped up that should work on both Unix and Windows platforms. Suggestions welcome.