@@ -14,10 +14,9 @@ use nix::fcntl::{OFlag, open};
1414use nix:: sys:: stat:: Mode ;
1515use std:: path:: Path ;
1616use uucore:: display:: Quotable ;
17- #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
18- use uucore:: error:: FromIo ;
19- use uucore:: error:: { UResult , USimpleError } ;
17+ use uucore:: error:: { UResult , USimpleError , get_exit_code, set_exit_code} ;
2018use uucore:: format_usage;
19+ use uucore:: show_error;
2120use uucore:: translate;
2221
2322pub mod options {
@@ -235,23 +234,30 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
235234 let path = Path :: new ( & f) ;
236235 if let Err ( e) = open ( path, OFlag :: O_NONBLOCK , Mode :: empty ( ) ) {
237236 if e != Errno :: EACCES || ( e == Errno :: EACCES && path. is_dir ( ) ) {
238- e. map_err_context (
239- || translate ! ( "sync-error-opening-file" , "file" => f. quote( ) ) ,
240- ) ?;
237+ show_error ! (
238+ "{}" ,
239+ translate!( "sync-error-opening-file" , "file" => f. quote( ) , "err" => e. desc( ) )
240+ ) ;
241+ set_exit_code ( 1 ) ;
241242 }
242243 }
243244 }
244245 #[ cfg( not( any( target_os = "linux" , target_os = "android" ) ) ) ]
245246 {
246247 if !Path :: new ( & f) . exists ( ) {
247- return Err ( USimpleError :: new (
248- 1 ,
249- translate ! ( "sync-error-no-such-file" , "file" => f. quote( ) ) ,
250- ) ) ;
248+ show_error ! (
249+ "{}" ,
250+ translate!( "sync-error-no-such-file" , "file" => f. quote( ) )
251+ ) ;
252+ set_exit_code ( 1 ) ;
251253 }
252254 }
253255 }
254256
257+ if get_exit_code ( ) != 0 {
258+ return Err ( USimpleError :: new ( 1 , "" ) ) ;
259+ }
260+
255261 #[ allow( clippy:: if_same_then_else) ]
256262 if matches. get_flag ( options:: FILE_SYSTEM ) {
257263 #[ cfg( any( target_os = "linux" , target_os = "android" , target_os = "windows" ) ) ]
0 commit comments