This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree 2 files changed +4
-8
lines changed 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -544,7 +544,7 @@ fn debug_print() {
544
544
545
545
let mut command_with_removed_env = Command :: new ( "boring-name" ) ;
546
546
command_with_removed_env. env_remove ( "FOO" ) . env_remove ( "BAR" ) ;
547
- assert_eq ! ( format!( "{command_with_removed_env:?}" ) , r#"unset BAR FOO && "boring-name""# ) ;
547
+ assert_eq ! ( format!( "{command_with_removed_env:?}" ) , r#"env -u BAR -u FOO "boring-name""# ) ;
548
548
assert_eq ! (
549
549
format!( "{command_with_removed_env:#?}" ) ,
550
550
format!(
Original file line number Diff line number Diff line change @@ -562,21 +562,17 @@ impl fmt::Debug for Command {
562
562
write ! ( f, "env -i " ) ?;
563
563
// Altered env vars will be printed next, that should exactly work as expected.
564
564
} else {
565
- // Removed env vars need a separate command.
566
- // We use a single `unset` command for all of them.
565
+ // Removed env vars need the command to be wrappen in `env`.
567
566
let mut any_removed = false ;
568
567
for ( key, value_opt) in self . get_envs ( ) {
569
568
if value_opt. is_none ( ) {
570
569
if !any_removed {
571
- write ! ( f, "unset " ) ?;
570
+ write ! ( f, "env " ) ?;
572
571
any_removed = true ;
573
572
}
574
- write ! ( f, "{} " , key. to_string_lossy( ) ) ?;
573
+ write ! ( f, "-u {} " , key. to_string_lossy( ) ) ?;
575
574
}
576
575
}
577
- if any_removed {
578
- write ! ( f, "&& " ) ?;
579
- }
580
576
}
581
577
// Altered env vars can just be added in front of the program.
582
578
for ( key, value_opt) in self . get_envs ( ) {
You can’t perform that action at this time.
0 commit comments