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

Document that Process::command will search the PATH #38018

Merged
merged 1 commit into from
Dec 1, 2016

Conversation

sourcefrog
Copy link
Contributor

No description provided.

@rust-highfive
Copy link
Collaborator

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@@ -253,6 +253,10 @@ impl Command {
/// Builder methods are provided to change these defaults and
/// otherwise configure the process.
///
/// The `PATH` from the Command's environment will be searched
/// if the program contains only a single path component, as for
/// `execvp`.
Copy link
Member

Choose a reason for hiding this comment

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

I don’t get what “as for execvp“ part is supposed to mean. Why are you including references to POSIX specific functions in documentation of platform agnostic part of documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I was wondering whether that would help make the behavior clearer to people or if it was better style not to mention it. I can remove that phrase.

Copy link
Member

Choose a reason for hiding this comment

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

I would just give a couple of examples - "For example, PATH will be searched for rustc but not bin/rustc".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

That isn't the case on Windows. It uses the child's PATH (badly: #37519) even if the program name contains multiple path components.

Windows and Linux have very different behaviour here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I saw that, what a mess.

The main thing I found missing here, as a reader, is that unqualified names will be searched along the PATH. (That's implied by some examples but I think worth having clear.)

I'd like to also say you can control that by setting the PATH environment, and it seems you can, except for various bugs on Windows. Perhaps this is too complex to get into here? It looks like general Rust style is not to mention bugs or caveats in the API docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So we could leave this as just

If program is not an absolute path, the PATH will be searched in an OS-defined way.

we could optionally add

The search path to be used may be controlled by setting the PATH environment variable on the Command,
but this has some implementation limitations on Windows (see #37519).

Copy link
Member

Choose a reason for hiding this comment

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

If program is not an absolute path, the PATH will be searched in an OS-defined way.

Something like that seems reasonable. I think the main thing that we need to include is that the behaviour is OS dependant.

@@ -253,6 +253,10 @@ impl Command {
/// Builder methods are provided to change these defaults and
/// otherwise configure the process.
///
/// The `PATH` from the Command's environment will be searched
Copy link
Member

@frewsxcv frewsxcv Nov 26, 2016

Choose a reason for hiding this comment

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

Nit:

... the `Command`'s environment...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@alexcrichton
Copy link
Member

@ollie27's concerns make sense to me, perhaps this could mention that the behavior is still platform-specific and basically just say that it's attempted to interpret PATH in the context of the child process, if required?

@sourcefrog
Copy link
Contributor Author

How about this?

@alexcrichton
Copy link
Member

Sounds reasonable to me! Looks like the tidy checks are failing though?

@sourcefrog
Copy link
Contributor Author

whitespace fixed.

@alexcrichton
Copy link
Member

Thanks! Could you also squash the commits?

@sourcefrog
Copy link
Contributor Author

Done, commits squashed

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Dec 1, 2016

📌 Commit db93677 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Dec 1, 2016

⌛ Testing commit db93677 with merge 149e76f...

bors added a commit that referenced this pull request Dec 1, 2016
Document that Process::command will search the PATH
@bors bors merged commit db93677 into rust-lang:master Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants