CC #148432
CC #149070
In the std::process::Command::get_resolved_envs example, we have the following code block:
#![feature(command_resolved_envs)]
use std::process::Command;
use std::ffi::{OsString, OsStr};
use std::env;
use std::collections::HashMap;
let mut cmd = Command::new("ls");
cmd.env("TZ", "UTC");
unsafe { env::set_var("EDITOR", "vim"); }
let resolved: HashMap<OsString, OsString> = cmd.get_resolved_envs().collect();
assert_eq!(resolved.get(OsStr::new("TZ")), Some(&OsString::from("UTC")));
assert_eq!(resolved.get(OsStr::new("EDITOR")), Some(&OsString::from("vim")));
The env::set_var runs concurrently to other doctests and is therefore unsound. Since it's an example for users to learn from, it should probably also mention to the user that setting env vars is unsafe in multi-threaded programs.
CC #148432
CC #149070
In the
std::process::Command::get_resolved_envsexample, we have the following code block:The
env::set_varruns concurrently to other doctests and is therefore unsound. Since it's an example for users to learn from, it should probably also mention to the user that setting env vars is unsafe in multi-threaded programs.