@@ -37,53 +37,53 @@ Rust implements the `env!()` and `option_env!()` macros to access the process en
3737
3838By default all environment variables are available with their value taken from the environment. There are several
3939additional controls to control the logical environment accessed by ` env!() ` /` option_env!() ` :
40- - only allow access to a specific whitelist of variables
40+ - only allow access to a specific set of variables
4141- override specific variables to other values
4242- add new variables without them being present in the environment
4343
4444These options are:
45- - ` --env-whitelist REGEX ` - match the REGEX against all existing process environment
46- variables and allow them to be seen. This overrides ` --env-remove-all ` . The regex is matched against the entire variable name
45+ - ` --env-allow REGEX ` - match the REGEX against all existing process environment
46+ variables and allow them to be seen. The regex is matched against the entire variable name
4747 (that is, it is anchored).
48- - ` --env-blacklist REGEX ` - match the REGEX against the environment and remove those variables from the logical environment; this
48+ - ` --env-deny REGEX ` - match the REGEX against the environment and remove those variables from the logical environment; this
4949 is equivalent to unsetting them from the Rust code's perspective.
5050- ` --env-set VAR=VALUE ` - set the logical value of an environment variable. This will override the value if it already exists
5151 in the process environment, or create a new logical environment variable.
5252
5353These options are processed in order. For example:
5454```
55- rustc --env-blacklist '.*' --env-whitelist 'CARGO_.*' --env-set HOME=/home/system [...]
55+ rustc --env-deny '.*' --env-allow 'CARGO_.*' --env-set HOME=/home/system [...]
5656```
5757will clean all environment variables from the logical environment. It then allows access to all Cargo-set variables, and overrides
5858the value of ` $HOME ` .
5959
6060Note that these options act on the logical environment, so:
6161```
62- rustc --env-set FOO=BAR --env-blacklist FOO
62+ rustc --env-set FOO=BAR --env-deny FOO
6363```
6464will leave ` FOO ` unset.
6565
6666# Reference-level explanation
6767[ reference-level-explanation ] : #reference-level-explanation
6868
6969The implementation of this RFC introduces the notion of a logical environment which is accessed by the ` env! ` /` option_env! ` macros,
70- distinct from the actual process environment. By default they are the same, but the additions of the ` --env-whitelist ` ,
71- ` --env-blacklist ` and ` --env-set ` options allow the logical environment to be tailored as desired.
70+ distinct from the actual process environment. By default they are the same, but the additions of the ` --env-allow ` ,
71+ ` --env-deny ` and ` --env-set ` options allow the logical environment to be tailored as desired.
7272
7373## Processing of the options
7474
7575The ` --env- ` options are processed in the order they appear on the command-line, left to right. The logical environment is
7676initialized from the process environment. Then each each ` --env ` option is processed in turn, as it appears, to update the logical
7777environment. Specifically:
7878
79- - ` --env-whitelist REGEX ` - Any name which doesn't match the REGEX is removed from the logical environment,
80- as if it had never been set. This is symmetric with ` --env-blacklist ` .
81- - ` --env-blacklist REGEX ` - Any name which does match the REGEX is removed from the logical environment, as if it had never
82- been set. This is symmetric with ` --env-whitelist ` .
79+ - ` --env-allow REGEX ` - Any name which doesn't match the REGEX is removed from the logical environment,
80+ as if it had never been set. This is symmetric with ` --env-deny ` .
81+ - ` --env-deny REGEX ` - Any name which does match the REGEX is removed from the logical environment, as if it had never
82+ been set. This is symmetric with ` --env-allow ` .
8383- ` --env-set VAR=VALUE ` - Set a logical environment variable with the given value. This either sets a new variable, or
8484 overrides an existing variable's value.
8585
86- Note that ` --env-whitelist ` and ` --env-blacklist ` affect variables set with previous ` --env-set ` options, possibly removing them.
86+ Note that ` --env-allow ` and ` --env-deny ` affect variables set with previous ` --env-set ` options, possibly removing them.
8787
8888If there are no ` --env- ` options then the logical environment is left in its initial state, which is identical to the process
8989environment.
@@ -117,7 +117,7 @@ it could constrain the accessible variables to:
117117
118118The primary cost is additional complexity in invoking ` rustc ` itself, and additional complexity in documenting
119119` env! ` /` option_env! ` . Procedual macros would need to be changed to access the logical environment, either by
120-
120+ adding new environment access APIs, or overriding the implementation of ` std::env::var ` (etc) for procmacros.
121121
122122# Rationale and alternatives
123123[ rationale-and-alternatives ] : #rationale-and-alternatives
0 commit comments