@@ -37,53 +37,53 @@ Rust implements the `env!()` and `option_env!()` macros to access the process en
37
37
38
38
By default all environment variables are available with their value taken from the environment. There are several
39
39
additional 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
41
41
- override specific variables to other values
42
42
- add new variables without them being present in the environment
43
43
44
44
These 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
47
47
(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
49
49
is equivalent to unsetting them from the Rust code's perspective.
50
50
- ` --env-set VAR=VALUE ` - set the logical value of an environment variable. This will override the value if it already exists
51
51
in the process environment, or create a new logical environment variable.
52
52
53
53
These options are processed in order. For example:
54
54
```
55
- rustc --env-blacklist '.*' --env-whitelist 'CARGO_.*' --env-set HOME=/home/system [...]
55
+ rustc --env-deny '.*' --env-allow 'CARGO_.*' --env-set HOME=/home/system [...]
56
56
```
57
57
will clean all environment variables from the logical environment. It then allows access to all Cargo-set variables, and overrides
58
58
the value of ` $HOME ` .
59
59
60
60
Note that these options act on the logical environment, so:
61
61
```
62
- rustc --env-set FOO=BAR --env-blacklist FOO
62
+ rustc --env-set FOO=BAR --env-deny FOO
63
63
```
64
64
will leave ` FOO ` unset.
65
65
66
66
# Reference-level explanation
67
67
[ reference-level-explanation ] : #reference-level-explanation
68
68
69
69
The 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.
72
72
73
73
## Processing of the options
74
74
75
75
The ` --env- ` options are processed in the order they appear on the command-line, left to right. The logical environment is
76
76
initialized from the process environment. Then each each ` --env ` option is processed in turn, as it appears, to update the logical
77
77
environment. Specifically:
78
78
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 ` .
83
83
- ` --env-set VAR=VALUE ` - Set a logical environment variable with the given value. This either sets a new variable, or
84
84
overrides an existing variable's value.
85
85
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.
87
87
88
88
If there are no ` --env- ` options then the logical environment is left in its initial state, which is identical to the process
89
89
environment.
@@ -117,7 +117,7 @@ it could constrain the accessible variables to:
117
117
118
118
The primary cost is additional complexity in invoking ` rustc ` itself, and additional complexity in documenting
119
119
` 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.
121
121
122
122
# Rationale and alternatives
123
123
[ rationale-and-alternatives ] : #rationale-and-alternatives
0 commit comments