-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add (unstable) documentation for
--env
command line option
- Loading branch information
1 parent
bafdbae
commit 556b447
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# `env` | ||
|
||
The tracking issue for this feature is: [#118372](https://github.com/rust-lang/rust/issues/118372). | ||
|
||
------------------------ | ||
|
||
This option flag allows to specify environment variables value at compile time to be | ||
used by `env!` and `option_env!` macros. | ||
|
||
When retrieving and environment variable value, the one specified by `--env` will take | ||
precedence. For example if you want have `PATH=a` in your environment and pass: | ||
|
||
```bash | ||
rustc --env PATH=env | ||
``` | ||
|
||
Then you will have: | ||
|
||
```rust | ||
assert_eq!(env!("PATH"), "env"); | ||
``` | ||
|
||
Please note that on Windows, environment variables are case insensitive but case | ||
preserving whereas `rustc`'s environment variables are case sensitive. For example, | ||
having `Path` in your environment (case insensitive) is different than using | ||
`rustc --env Path=...` (case sensitive). |