This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -452,7 +452,7 @@ fn env_empty() {
452452#[ test]
453453#[ cfg( not( windows) ) ]
454454#[ cfg_attr( any( target_os = "emscripten" , target_env = "sgx" ) , ignore) ]
455- fn main ( ) {
455+ fn debug_print ( ) {
456456 const PIDFD : & ' static str =
457457 if cfg ! ( target_os = "linux" ) { " create_pidfd: false,\n " } else { "" } ;
458458
@@ -538,6 +538,27 @@ fn main() {
538538 cwd: Some(
539539 "/some/path",
540540 ),
541+ {PIDFD}}}"#
542+ )
543+ ) ;
544+
545+ let mut command_with_removed_env = Command :: new ( "boring-name" ) ;
546+ command_with_removed_env. env_remove ( "BAR" ) ;
547+ assert_eq ! ( format!( "{command_with_removed_env:?}" ) , r#"unset(BAR) "boring-name""# ) ;
548+ assert_eq ! (
549+ format!( "{command_with_removed_env:#?}" ) ,
550+ format!(
551+ r#"Command {{
552+ program: "boring-name",
553+ args: [
554+ "boring-name",
555+ ],
556+ env: CommandEnv {{
557+ clear: false,
558+ vars: {{
559+ "BAR": None,
560+ }},
561+ }},
541562{PIDFD}}}"#
542563 )
543564 ) ;
Original file line number Diff line number Diff line change @@ -561,6 +561,8 @@ impl fmt::Debug for Command {
561561 for ( key, value_opt) in self . get_envs ( ) {
562562 if let Some ( value) = value_opt {
563563 write ! ( f, "{}={value:?} " , key. to_string_lossy( ) ) ?;
564+ } else {
565+ write ! ( f, "unset({}) " , key. to_string_lossy( ) ) ?;
564566 }
565567 }
566568 if self . program != self . args [ 0 ] {
You can’t perform that action at this time.
0 commit comments