File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -135,14 +135,15 @@ impl Command {
135135 Some ( envp) => {
136136 match envp. get_items ( ) . iter ( ) . find ( |var| var. as_bytes ( ) . starts_with ( b"PATH=" ) ) {
137137 Some ( p) => & p. as_bytes ( ) [ 5 ..] ,
138- None => return None ,
138+ // Chosen to match what glibc does if there's no PATH variable
139+ None => b"/bin:/usr/bin" ,
139140 }
140141 } ,
141142 // maybe_envp is None if the process isn't changing the parent's env at all.
142143 None => {
143144 match parent_path. as_ref ( ) {
144145 Some ( p) => p. as_bytes ( ) ,
145- None => return None ,
146+ None => b"/bin:/usr/bin" ,
146147 }
147148 } ,
148149 } ;
Original file line number Diff line number Diff line change @@ -55,6 +55,16 @@ fn main() {
5555 println ! ( "passed" ) ;
5656 }
5757
58+ "exec-test6" => {
59+ let err = Command :: new ( "echo" ) . arg ( "passed" ) . env_clear ( ) . exec ( ) ;
60+ panic ! ( "failed to spawn: {}" , err) ;
61+ }
62+
63+ "exec-test7" => {
64+ let err = Command :: new ( "echo" ) . arg ( "passed" ) . env_remove ( "PATH" ) . exec ( ) ;
65+ panic ! ( "failed to spawn: {}" , err) ;
66+ }
67+
5868 _ => panic ! ( "unknown argument: {}" , arg) ,
5969 }
6070 return
@@ -84,4 +94,14 @@ fn main() {
8494 assert ! ( output. status. success( ) ) ;
8595 assert ! ( output. stderr. is_empty( ) ) ;
8696 assert_eq ! ( output. stdout, b"passed\n " ) ;
97+
98+ let output = Command :: new ( & me) . arg ( "exec-test6" ) . output ( ) . unwrap ( ) ;
99+ assert ! ( output. status. success( ) ) ;
100+ assert ! ( output. stderr. is_empty( ) ) ;
101+ assert_eq ! ( output. stdout, b"passed\n " ) ;
102+
103+ let output = Command :: new ( & me) . arg ( "exec-test7" ) . output ( ) . unwrap ( ) ;
104+ assert ! ( output. status. success( ) ) ;
105+ assert ! ( output. stderr. is_empty( ) ) ;
106+ assert_eq ! ( output. stdout, b"passed\n " ) ;
87107}
You can’t perform that action at this time.
0 commit comments