File tree 2 files changed +23
-2
lines changed
2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -135,14 +135,15 @@ impl Command {
135
135
Some ( envp) => {
136
136
match envp. get_items ( ) . iter ( ) . find ( |var| var. as_bytes ( ) . starts_with ( b"PATH=" ) ) {
137
137
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" ,
139
140
}
140
141
} ,
141
142
// maybe_envp is None if the process isn't changing the parent's env at all.
142
143
None => {
143
144
match parent_path. as_ref ( ) {
144
145
Some ( p) => p. as_bytes ( ) ,
145
- None => return None ,
146
+ None => b"/bin:/usr/bin" ,
146
147
}
147
148
} ,
148
149
} ;
Original file line number Diff line number Diff line change @@ -55,6 +55,16 @@ fn main() {
55
55
println ! ( "passed" ) ;
56
56
}
57
57
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
+
58
68
_ => panic ! ( "unknown argument: {}" , arg) ,
59
69
}
60
70
return
@@ -84,4 +94,14 @@ fn main() {
84
94
assert ! ( output. status. success( ) ) ;
85
95
assert ! ( output. stderr. is_empty( ) ) ;
86
96
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 " ) ;
87
107
}
You can’t perform that action at this time.
0 commit comments