@@ -15,9 +15,10 @@ use uucore::format_usage;
1515
1616use std:: borrow:: Cow ;
1717use std:: ffi:: { CStr , CString , OsStr , OsString } ;
18- use std:: os :: raw :: c_char ;
18+ use std:: io ;
1919use std:: os:: unix:: ffi:: OsStrExt ;
20- use std:: { io, ptr} ;
20+ use std:: os:: unix:: process:: CommandExt ;
21+ use std:: process;
2122
2223mod errors;
2324
@@ -367,23 +368,8 @@ fn get_custom_context(
367368/// compiler the only valid return type is to say "if this returns, it will
368369/// always return an error".
369370fn execute_command ( command : & OsStr , arguments : & [ OsString ] ) -> UResult < ( ) > {
370- let c_command = os_str_to_c_string ( command) . map_err ( RunconError :: new ) ? ;
371+ let err = process :: Command :: new ( command) . args ( arguments ) . exec ( ) ;
371372
372- let argv_storage: Vec < CString > = arguments
373- . iter ( )
374- . map ( AsRef :: as_ref)
375- . map ( os_str_to_c_string)
376- . collect :: < Result < _ > > ( )
377- . map_err ( RunconError :: new) ?;
378-
379- let mut argv: Vec < * const c_char > = Vec :: with_capacity ( arguments. len ( ) . saturating_add ( 2 ) ) ;
380- argv. push ( c_command. as_ptr ( ) ) ;
381- argv. extend ( argv_storage. iter ( ) . map ( AsRef :: as_ref) . map ( CStr :: as_ptr) ) ;
382- argv. push ( ptr:: null ( ) ) ;
383-
384- unsafe { libc:: execvp ( c_command. as_ptr ( ) , argv. as_ptr ( ) ) } ;
385-
386- let err = io:: Error :: last_os_error ( ) ;
387373 let exit_status = if err. kind ( ) == io:: ErrorKind :: NotFound {
388374 error_exit_status:: NOT_FOUND
389375 } else {
0 commit comments