@@ -88,21 +88,31 @@ impl Process {
8888 }
8989
9090 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) ? ,
9393 #[ cfg( feature = "test" ) ]
9494 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 ) ,
9797 } ,
98+ } ;
99+
100+ match value. is_empty ( ) {
101+ false => Ok ( value) ,
102+ true => Err ( env:: VarError :: NotPresent ) ,
98103 }
99104 }
100105
101106 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) ? ,
104109 #[ 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 ,
106116 }
107117 }
108118
0 commit comments