-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
docs: clarification for Unix.open_process_args_in #10057
docs: clarification for Unix.open_process_args_in #10057
Conversation
cb6c964
to
fab57a8
Compare
Searching the web suggests that you are far from the only one to make this mistake. See for example this piece of Reason code let ic =
Sys.win32
// HACK: Not sure why this command doesn't work on Linux / macOS, and vice versa...
? Unix.open_process_args_in(
"node",
[|"node", "-e", "console.log(process.execPath)"|],
)
: Unix.open_process_in("node -e 'console.log(process.execPath)'"); It looks like Windows resolves the executable name passed to open_process_args*, adding to the confusion. Could you maybe consider adding an example use in the documentation, which would make the recommendations visually obvious? Code blocks in ocamldoc use the . I wonder if we should consider changing An alternative since OCaml 4.10 is to use |
(cc @xavierleroy @nojb) |
Indeed, to summarize my recollection:
So indeed it looks like there is a mismatch between Unix/Windows regarding the args functions. This may have been overlooked when the args functions where introduced because up until that point, only So to summarize, looks like replacing |
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 proposed documentation is correct. However, the convention on argument arrays (that the first element matches the command name and the subsequent elements are the arguments proper) is consistently used in the Unix library, e.g. in execv
, execve
, execvp
, execvpe
, create_process
, create_process_env
, open_process_args_in
, open_process_args_out
, open_process_args
, and open_process_args_full
. So, documenting it for open_process_args_in
and not for any other function is problematic.
It is a plausible change, making these functions more usable, with a small backward incompatibility. However it is not a "fix for the present issue", which also includes a misunderstanding of what an "argument array" is in the Unix world. This is a bit of information that should be put somewhere but not repeated 10 times for the 10 Unix functions that are affected. |
And for the misunderstanding of what an "argument array" is in the Unix world, I think the proposed changed is misleading. The first argument doesn't have to match the name of the command ( the best explananation I found), it should be present but can be arbitrary, except if the command use it for modifying its behavior. |
I created a separate issue for the |
Superseded by #10084. |
I tripped myself up on this as can be seen here. Hoping this small change will help others in the future.
I used the Conventional Commits style, I hope that's okay.