@@ -88,21 +88,31 @@ impl Process {
88
88
}
89
89
90
90
pub fn var ( & self , key : & str ) -> Result < String , env:: VarError > {
91
- match self {
92
- Process :: OsProcess ( _) => env:: var ( key) ,
91
+ let value = match self {
92
+ Process :: OsProcess ( _) => env:: var ( key) ? ,
93
93
#[ cfg( feature = "test" ) ]
94
94
Process :: TestProcess ( p) => match p. vars . get ( key) {
95
- Some ( val) => Ok ( val. to_owned ( ) ) ,
96
- None => Err ( env:: VarError :: NotPresent ) ,
95
+ Some ( val) => val. to_owned ( ) ,
96
+ None => return Err ( env:: VarError :: NotPresent ) ,
97
97
} ,
98
+ } ;
99
+
100
+ match value. is_empty ( ) {
101
+ false => Ok ( value) ,
102
+ true => Err ( env:: VarError :: NotPresent ) ,
98
103
}
99
104
}
100
105
101
106
pub ( crate ) fn var_os ( & self , key : & str ) -> Option < OsString > {
102
- match self {
103
- Process :: OsProcess ( _) => env:: var_os ( key) ,
107
+ let value = match self {
108
+ Process :: OsProcess ( _) => env:: var_os ( key) ? ,
104
109
#[ cfg( feature = "test" ) ]
105
- Process :: TestProcess ( p) => p. vars . get ( key) . map ( OsString :: from) ,
110
+ Process :: TestProcess ( p) => p. vars . get ( key) . map ( OsString :: from) ?,
111
+ } ;
112
+
113
+ match value. is_empty ( ) {
114
+ false => Some ( value) ,
115
+ true => None ,
106
116
}
107
117
}
108
118
0 commit comments