clear env by default

This commit is contained in:
atagen 2025-11-02 23:21:49 +11:00
parent fd5de5e9bb
commit 861de08a9b
3 changed files with 4 additions and 4 deletions

View file

@ -156,7 +156,7 @@ examples
if opts.exec.len() > 1 {
cmd.args(&opts.exec[1..]);
}
if opts.clear_env {
if !opts.retain_env {
for (k, _) in std::env::vars() {
unsafe {
std::env::remove_var(k);

View file

@ -138,11 +138,11 @@ pub fn parse_args() -> Result<Yoke> {
cur_arg = Unset;
yoke.signals = true;
}
"--clear-env" | "-c" => {
"--retain-env" | "-r" => {
collect_args(&mut yoke, &collector, &cur_arg)?;
collector.clear();
cur_arg = Unset;
yoke.clear_env = true;
yoke.retain_env = true;
}
"--ldd" | "-l" => {
collect_args(&mut yoke, &collector, &cur_arg)?;

View file

@ -5,7 +5,7 @@ pub struct Yoke {
pub fs: HashMap<Permissions, Vec<PathBuf>>,
pub tcp: HashMap<Direction, Vec<u16>>,
pub env: HashMap<String, String>,
pub clear_env: bool,
pub retain_env: bool,
pub signals: bool,
pub sockets: bool,
pub ldd: bool,