@@ -85,7 +85,13 @@ impl Client {
85
85
if let Some ( client) = Self :: from_fifo ( s) ? {
86
86
return Ok ( client) ;
87
87
}
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
+ ) )
89
95
}
90
96
91
97
/// `--jobserver-auth=fifo:PATH`
@@ -106,13 +112,13 @@ impl Client {
106
112
}
107
113
108
114
/// `--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 > > {
110
116
let mut parts = s. splitn ( 2 , ',' ) ;
111
117
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
+ } ;
116
122
let read = read
117
123
. parse ( )
118
124
. map_err ( |e| io:: Error :: new ( io:: ErrorKind :: Other , e) ) ?;
@@ -132,7 +138,7 @@ impl Client {
132
138
check_fd ( write) ?;
133
139
drop ( set_cloexec ( read, true ) ) ;
134
140
drop ( set_cloexec ( write, true ) ) ;
135
- Ok ( Client :: from_fds ( read, write) )
141
+ Ok ( Some ( Client :: from_fds ( read, write) ) )
136
142
}
137
143
138
144
unsafe fn from_fds ( read : c_int , write : c_int ) -> Client {
0 commit comments