@@ -254,44 +254,37 @@ impl Command {
254
254
// have the drop glue anyway because this code never returns (the
255
255
// child will either exec() or invoke syscall::exit)
256
256
unsafe fn do_exec ( & mut self , stdio : ChildPipes ) -> io:: Error {
257
- macro_rules! t {
258
- ( $e: expr) => ( match $e {
259
- Ok ( e) => e,
260
- Err ( e) => return e,
261
- } )
262
- }
263
-
264
257
if let Some ( fd) = stdio. stderr . fd ( ) {
265
- t ! ( cvt( syscall:: dup2( fd, 2 , & [ ] ) ) ) ;
266
- let mut flags = t ! ( cvt( syscall:: fcntl( 2 , syscall:: F_GETFD , 0 ) ) ) ;
258
+ cvt ( syscall:: dup2 ( fd, 2 , & [ ] ) ) ? ;
259
+ let mut flags = cvt ( syscall:: fcntl ( 2 , syscall:: F_GETFD , 0 ) ) ? ;
267
260
flags &= ! syscall:: O_CLOEXEC ;
268
- t ! ( cvt( syscall:: fcntl( 2 , syscall:: F_SETFD , flags) ) ) ;
261
+ cvt ( syscall:: fcntl ( 2 , syscall:: F_SETFD , flags) ) ? ;
269
262
}
270
263
if let Some ( fd) = stdio. stdout . fd ( ) {
271
- t ! ( cvt( syscall:: dup2( fd, 1 , & [ ] ) ) ) ;
272
- let mut flags = t ! ( cvt( syscall:: fcntl( 1 , syscall:: F_GETFD , 0 ) ) ) ;
264
+ cvt ( syscall:: dup2 ( fd, 1 , & [ ] ) ) ? ;
265
+ let mut flags = cvt ( syscall:: fcntl ( 1 , syscall:: F_GETFD , 0 ) ) ? ;
273
266
flags &= ! syscall:: O_CLOEXEC ;
274
- t ! ( cvt( syscall:: fcntl( 1 , syscall:: F_SETFD , flags) ) ) ;
267
+ cvt ( syscall:: fcntl ( 1 , syscall:: F_SETFD , flags) ) ? ;
275
268
}
276
269
if let Some ( fd) = stdio. stdin . fd ( ) {
277
- t ! ( cvt( syscall:: dup2( fd, 0 , & [ ] ) ) ) ;
278
- let mut flags = t ! ( cvt( syscall:: fcntl( 0 , syscall:: F_GETFD , 0 ) ) ) ;
270
+ cvt ( syscall:: dup2 ( fd, 0 , & [ ] ) ) ? ;
271
+ let mut flags = cvt ( syscall:: fcntl ( 0 , syscall:: F_GETFD , 0 ) ) ? ;
279
272
flags &= ! syscall:: O_CLOEXEC ;
280
- t ! ( cvt( syscall:: fcntl( 0 , syscall:: F_SETFD , flags) ) ) ;
273
+ cvt ( syscall:: fcntl ( 0 , syscall:: F_SETFD , flags) ) ? ;
281
274
}
282
275
283
276
if let Some ( g) = self . gid {
284
- t ! ( cvt( syscall:: setregid( g as usize , g as usize ) ) ) ;
277
+ cvt ( syscall:: setregid ( g as usize , g as usize ) ) ? ;
285
278
}
286
279
if let Some ( u) = self . uid {
287
- t ! ( cvt( syscall:: setreuid( u as usize , u as usize ) ) ) ;
280
+ cvt ( syscall:: setreuid ( u as usize , u as usize ) ) ? ;
288
281
}
289
282
if let Some ( ref cwd) = self . cwd {
290
- t ! ( cvt( syscall:: chdir( cwd) ) ) ;
283
+ cvt ( syscall:: chdir ( cwd) ) ? ;
291
284
}
292
285
293
286
for callback in self . closures . iter_mut ( ) {
294
- t ! ( callback( ) ) ;
287
+ callback ( ) ? ;
295
288
}
296
289
297
290
self . env . apply ( ) ;
@@ -313,7 +306,7 @@ impl Command {
313
306
} ;
314
307
315
308
let mut file = if let Some ( program) = program {
316
- t ! ( File :: open( program. as_os_str( ) ) )
309
+ File :: open ( program. as_os_str ( ) ) ?
317
310
} else {
318
311
return io:: Error :: from_raw_os_error ( syscall:: ENOENT ) ;
319
312
} ;
@@ -327,7 +320,7 @@ impl Command {
327
320
let mut shebang = [ 0 ; 2 ] ;
328
321
let mut read = 0 ;
329
322
loop {
330
- match t ! ( reader. read( & mut shebang[ read..] ) ) {
323
+ match reader. read ( & mut shebang[ read..] ) ? {
331
324
0 => break ,
332
325
n => read += n,
333
326
}
@@ -338,9 +331,9 @@ impl Command {
338
331
// First of all, since we'll be passing another file to
339
332
// fexec(), we need to manually check that we have permission
340
333
// to execute this file:
341
- let uid = t ! ( cvt( syscall:: getuid( ) ) ) ;
342
- let gid = t ! ( cvt( syscall:: getgid( ) ) ) ;
343
- let meta = t ! ( file. metadata( ) ) ;
334
+ let uid = cvt ( syscall:: getuid ( ) ) ? ;
335
+ let gid = cvt ( syscall:: getgid ( ) ) ? ;
336
+ let meta = file. metadata ( ) ? ;
344
337
345
338
let mode = if uid == meta. uid ( ) as usize {
346
339
meta. mode ( ) >> 3 * 2 & 0o7
@@ -355,7 +348,7 @@ impl Command {
355
348
356
349
// Second of all, we need to actually read which interpreter it wants
357
350
let mut interpreter = Vec :: new ( ) ;
358
- t ! ( reader. read_until( b'\n' , & mut interpreter) ) ;
351
+ reader. read_until ( b'\n' , & mut interpreter) ? ;
359
352
// Pop one trailing newline, if any
360
353
if interpreter. ends_with ( & [ b'\n' ] ) {
361
354
interpreter. pop ( ) . unwrap ( ) ;
@@ -373,11 +366,11 @@ impl Command {
373
366
} ;
374
367
if let Some ( ref interpreter) = interpreter {
375
368
let path: & OsStr = OsStr :: from_bytes ( & interpreter) ;
376
- file = t ! ( File :: open( path) ) ;
369
+ file = File :: open ( path) ? ;
377
370
378
371
args. push ( [ interpreter. as_ptr ( ) as usize , interpreter. len ( ) ] ) ;
379
372
} else {
380
- t ! ( file. seek( SeekFrom :: Start ( 0 ) ) ) ;
373
+ file. seek ( SeekFrom :: Start ( 0 ) ) ? ;
381
374
}
382
375
383
376
args. push ( [ self . program . as_ptr ( ) as usize , self . program . len ( ) ] ) ;
0 commit comments