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() {
452
452
#[ test]
453
453
#[ cfg( not( windows) ) ]
454
454
#[ cfg_attr( any( target_os = "emscripten" , target_env = "sgx" ) , ignore) ]
455
- fn main ( ) {
455
+ fn debug_print ( ) {
456
456
const PIDFD : & ' static str =
457
457
if cfg ! ( target_os = "linux" ) { " create_pidfd: false,\n " } else { "" } ;
458
458
@@ -538,6 +538,27 @@ fn main() {
538
538
cwd: Some(
539
539
"/some/path",
540
540
),
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
+ }},
541
562
{PIDFD}}}"#
542
563
)
543
564
) ;
Original file line number Diff line number Diff line change @@ -561,6 +561,8 @@ impl fmt::Debug for Command {
561
561
for ( key, value_opt) in self . get_envs ( ) {
562
562
if let Some ( value) = value_opt {
563
563
write ! ( f, "{}={value:?} " , key. to_string_lossy( ) ) ?;
564
+ } else {
565
+ write ! ( f, "unset({}) " , key. to_string_lossy( ) ) ?;
564
566
}
565
567
}
566
568
if self . program != self . args [ 0 ] {
You can’t perform that action at this time.
0 commit comments