@@ -254,44 +254,37 @@ impl Command {
254254 // have the drop glue anyway because this code never returns (the
255255 // child will either exec() or invoke syscall::exit)
256256 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-
264257 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 ) ) ? ;
267260 flags &= ! syscall:: O_CLOEXEC ;
268- t ! ( cvt( syscall:: fcntl( 2 , syscall:: F_SETFD , flags) ) ) ;
261+ cvt ( syscall:: fcntl ( 2 , syscall:: F_SETFD , flags) ) ? ;
269262 }
270263 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 ) ) ? ;
273266 flags &= ! syscall:: O_CLOEXEC ;
274- t ! ( cvt( syscall:: fcntl( 1 , syscall:: F_SETFD , flags) ) ) ;
267+ cvt ( syscall:: fcntl ( 1 , syscall:: F_SETFD , flags) ) ? ;
275268 }
276269 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 ) ) ? ;
279272 flags &= ! syscall:: O_CLOEXEC ;
280- t ! ( cvt( syscall:: fcntl( 0 , syscall:: F_SETFD , flags) ) ) ;
273+ cvt ( syscall:: fcntl ( 0 , syscall:: F_SETFD , flags) ) ? ;
281274 }
282275
283276 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 ) ) ? ;
285278 }
286279 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 ) ) ? ;
288281 }
289282 if let Some ( ref cwd) = self . cwd {
290- t ! ( cvt( syscall:: chdir( cwd) ) ) ;
283+ cvt ( syscall:: chdir ( cwd) ) ? ;
291284 }
292285
293286 for callback in self . closures . iter_mut ( ) {
294- t ! ( callback( ) ) ;
287+ callback ( ) ? ;
295288 }
296289
297290 self . env . apply ( ) ;
@@ -313,7 +306,7 @@ impl Command {
313306 } ;
314307
315308 let mut file = if let Some ( program) = program {
316- t ! ( File :: open( program. as_os_str( ) ) )
309+ File :: open ( program. as_os_str ( ) ) ?
317310 } else {
318311 return io:: Error :: from_raw_os_error ( syscall:: ENOENT ) ;
319312 } ;
@@ -327,7 +320,7 @@ impl Command {
327320 let mut shebang = [ 0 ; 2 ] ;
328321 let mut read = 0 ;
329322 loop {
330- match t ! ( reader. read( & mut shebang[ read..] ) ) {
323+ match reader. read ( & mut shebang[ read..] ) ? {
331324 0 => break ,
332325 n => read += n,
333326 }
@@ -338,9 +331,9 @@ impl Command {
338331 // First of all, since we'll be passing another file to
339332 // fexec(), we need to manually check that we have permission
340333 // 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 ( ) ? ;
344337
345338 let mode = if uid == meta. uid ( ) as usize {
346339 meta. mode ( ) >> 3 * 2 & 0o7
@@ -355,7 +348,7 @@ impl Command {
355348
356349 // Second of all, we need to actually read which interpreter it wants
357350 let mut interpreter = Vec :: new ( ) ;
358- t ! ( reader. read_until( b'\n' , & mut interpreter) ) ;
351+ reader. read_until ( b'\n' , & mut interpreter) ? ;
359352 // Pop one trailing newline, if any
360353 if interpreter. ends_with ( & [ b'\n' ] ) {
361354 interpreter. pop ( ) . unwrap ( ) ;
@@ -373,11 +366,11 @@ impl Command {
373366 } ;
374367 if let Some ( ref interpreter) = interpreter {
375368 let path: & OsStr = OsStr :: from_bytes ( & interpreter) ;
376- file = t ! ( File :: open( path) ) ;
369+ file = File :: open ( path) ? ;
377370
378371 args. push ( [ interpreter. as_ptr ( ) as usize , interpreter. len ( ) ] ) ;
379372 } else {
380- t ! ( file. seek( SeekFrom :: Start ( 0 ) ) ) ;
373+ file. seek ( SeekFrom :: Start ( 0 ) ) ? ;
381374 }
382375
383376 args. push ( [ self . program . as_ptr ( ) as usize , self . program . len ( ) ] ) ;
0 commit comments