@@ -85,7 +85,13 @@ impl Client {
8585 if let Some ( client) = Self :: from_fifo ( s) ? {
8686 return Ok ( client) ;
8787 }
88- Self :: from_pipe ( s)
88+ if let Some ( client) = Self :: from_pipe ( s) ? {
89+ return Ok ( client) ;
90+ }
91+ Err ( io:: Error :: new (
92+ io:: ErrorKind :: InvalidInput ,
93+ "unrecognized format of environment variable" ,
94+ ) )
8995 }
9096
9197 /// `--jobserver-auth=fifo:PATH`
@@ -106,13 +112,13 @@ impl Client {
106112 }
107113
108114 /// `--jobserver-auth=R,W`
109- unsafe fn from_pipe ( s : & str ) -> io:: Result < Client > {
115+ unsafe fn from_pipe ( s : & str ) -> io:: Result < Option < Client > > {
110116 let mut parts = s. splitn ( 2 , ',' ) ;
111117 let read = parts. next ( ) . unwrap ( ) ;
112- let write = parts. next ( ) . ok_or ( io :: Error :: new (
113- io :: ErrorKind :: InvalidInput ,
114- "expected ',' in `auth=R,W`" ,
115- ) ) ? ;
118+ let write = match parts. next ( ) {
119+ Some ( w ) => w ,
120+ None => return Ok ( None ) ,
121+ } ;
116122 let read = read
117123 . parse ( )
118124 . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: Other , e) ) ?;
@@ -132,7 +138,7 @@ impl Client {
132138 check_fd ( write) ?;
133139 drop ( set_cloexec ( read, true ) ) ;
134140 drop ( set_cloexec ( write, true ) ) ;
135- Ok ( Client :: from_fds ( read, write) )
141+ Ok ( Some ( Client :: from_fds ( read, write) ) )
136142 }
137143
138144 unsafe fn from_fds ( read : c_int , write : c_int ) -> Client {
0 commit comments