-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add Command environment variable inheritance docs #109272
Add Command environment variable inheritance docs #109272
Conversation
r? @cuviper (rustbot has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
The interaction between the environment variable methods can be confusing. Specifically `env_clear` and `remove_env` have a side effects not mentioned: they disable inheriting environment variables from the parent process. I wanted to fully document this behavior as well as explain relevant edge cases in each of the `Command` env methods. This is further confused by the return of `get_envs` which will return key/None if `remove_env` has been used, but an empty iterator if `env_clear` has been called. Or a non-empty iterator if `env_clear` was called and later explicit mappings are added. Currently there is no way (that I'm able to find) of observing whether or not the internal `env_clear=true` been toggled on the `Command` struct via its public API. Ultimately environment variable mappings can be in one of several states: - Explicitly set value (via `envs` / `env`) will take precedence over parent mapping - Not explicitly set, will inherit mapping from parent - Explicitly removed via `remove_env`, this single mapping will not inherit from parent - Implicitly removed via `env_clear`, no mappings will inherit from parent I tried to represent this in the relevant sections of the docs. This is my second ever doc PR (whoop!). I'm happy to take specific or general doc feedback. Also happy to explain the logic behind any changes or additions I made.
5faaf33
to
75657d5
Compare
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
AFAICT you've accurately captured the current behavior, but I'm going to flip this over to API review, since documentation implies a stronger promise about maintaining that exactly. r? libs-api |
r=me once @cuviper's comment is addressed |
Fixes documentation. I wrote `env_clear` when I meant `env_remove`. Good catch. Co-authored-by: Josh Stone <cuviper@gmail.com>
Sorry for the delay. I applied @cuviper's suggestion, it was a good catch. Thanks for the reviews and all your work on rust ❤️ Let me know if this needs anything else. |
Could not assign reviewer from: |
The intent of saying " @bors r=Amanieu |
@bors rollup -- just docs here |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#108687 (Reformulate `point_at_expr_source_of_inferred_type` to be more accurate) - rust-lang#109272 (Add Command environment variable inheritance docs) - rust-lang#109947 (Add links from `core::cmp` derives to their traits) - rust-lang#110110 (Use `Display` in top-level example for `PanicInfo`) - rust-lang#110154 (Fix typos in library) - rust-lang#110244 (Remove some unneeded imports / qualified paths) - rust-lang#110328 ([rustdoc] Add explanations for auto-disambiguation when an intra doc link is resolved to a proc-macro and a trait at the same time) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
The interaction between the environment variable methods can be confusing. Specifically
env_clear
andremove_env
have a side effects not mentioned: they disable inheriting environment variables from the parent process. I wanted to fully document this behavior as well as explain relevant edge cases in each of theCommand
env methods.This is further confused by the return of
get_envs
which will return key/None ifremove_env
has been used, but an empty iterator ifenv_clear
has been called. Or a non-empty iterator ifenv_clear
was called and later explicit mappings are added. Currently there is no way (that I'm able to find) of observing whether or not the internalenv_clear=true
been toggled on theCommand
struct via its public API.Ultimately environment variable mappings can be in one of several states:
envs
/env
) will take precedence over parent mappingremove_env
, this single mapping will not inherit from parentenv_clear
, no mappings will inherit from parentI tried to represent this in the relevant sections of the docs.
This is my second-ever doc PR (whoop!). I'm happy to take specific or general doc feedback. Also happy to explain the logic behind any changes or additions I made.