Skip to content

Commit 38effb3

Browse files
committed
Auto merge of rust-lang#2293 - RalfJung:env, r=RalfJung
make -Zmiri-env-forward take precedence over -Zmiri-env-exclude Lets people experiment with the `TERM` env var.
2 parents 3b1fc83 + aef78d3 commit 38effb3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,9 @@ environment variable. We first document the most relevant and most commonly used
285285
harness](https://github.com/rust-lang/miri/issues/1702). This has no effect unless
286286
`-Zmiri-disable-isolation` is also set.
287287
* `-Zmiri-env-forward=<var>` forwards the `var` environment variable to the interpreted program. Can
288-
be used multiple times to forward several variables. This has no effect if
289-
`-Zmiri-disable-isolation` is set.
288+
be used multiple times to forward several variables. This takes precedence over
289+
`-Zmiri-env-exclude`: if a variable is both forwarded and exluced, it *will* get forwarded. This
290+
means in particular `-Zmiri-env-forward=TERM` overwrites the default exclusion of `TERM`.
290291
* `-Zmiri-ignore-leaks` disables the memory leak checker, and also allows some
291292
remaining threads to exist when the main thread exits.
292293
* `-Zmiri-permissive-provenance` disables the warning for integer-to-pointer casts and

src/shims/env.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ impl<'tcx> EnvVars<'tcx> {
5050
// Skip the loop entirely if we don't want to forward anything.
5151
if ecx.machine.communicate() || !config.forwarded_env_vars.is_empty() {
5252
for (name, value) in env::vars_os() {
53-
let forward = match ecx.machine.communicate() {
54-
true => !excluded_env_vars.iter().any(|v| **v == name),
55-
false => config.forwarded_env_vars.iter().any(|v| **v == name),
56-
};
53+
// Always forward what is in `forwarded_env_vars`; that list can take precedence over excluded_env_vars.
54+
let forward = config.forwarded_env_vars.iter().any(|v| **v == name)
55+
|| (ecx.machine.communicate()
56+
&& !excluded_env_vars.iter().any(|v| **v == name));
5757
if forward {
5858
let var_ptr = match target_os {
5959
target if target_os_is_unix(target) =>

0 commit comments

Comments
 (0)