File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -544,7 +544,7 @@ fn debug_print() {
544544
545545 let mut command_with_removed_env = Command :: new ( "boring-name" ) ;
546546 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""# ) ;
548548 assert_eq ! (
549549 format!( "{command_with_removed_env:#?}" ) ,
550550 format!(
Original file line number Diff line number Diff line change @@ -562,21 +562,17 @@ impl fmt::Debug for Command {
562562 write ! ( f, "env -i " ) ?;
563563 // Altered env vars will be printed next, that should exactly work as expected.
564564 } 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`.
567566 let mut any_removed = false ;
568567 for ( key, value_opt) in self . get_envs ( ) {
569568 if value_opt. is_none ( ) {
570569 if !any_removed {
571- write ! ( f, "unset " ) ?;
570+ write ! ( f, "env " ) ?;
572571 any_removed = true ;
573572 }
574- write ! ( f, "{} " , key. to_string_lossy( ) ) ?;
573+ write ! ( f, "-u {} " , key. to_string_lossy( ) ) ?;
575574 }
576575 }
577- if any_removed {
578- write ! ( f, "&& " ) ?;
579- }
580576 }
581577 // Altered env vars can just be added in front of the program.
582578 for ( key, value_opt) in self . get_envs ( ) {
You can’t perform that action at this time.
0 commit comments