@@ -27,6 +27,7 @@ use std::env;
27
27
use std:: ffi:: { OsStr , OsString } ;
28
28
use std:: io:: { self , Write , ErrorKind } ;
29
29
use std:: path:: { Component , PathBuf } ;
30
+ use std:: process:: exit;
30
31
31
32
use ansiterm:: { ANSIStrings , Style } ;
32
33
@@ -87,8 +88,6 @@ lazy_static! {
87
88
}
88
89
89
90
fn main ( ) {
90
- use std:: process:: exit;
91
-
92
91
#[ cfg( unix) ]
93
92
unsafe {
94
93
libc:: signal ( libc:: SIGPIPE , libc:: SIG_DFL ) ;
@@ -118,8 +117,11 @@ fn main() {
118
117
let theme = options. theme . to_theme ( terminal_size:: terminal_size ( ) . is_some ( ) ) ;
119
118
let exa = Exa { options, writer, input_paths, theme, console_width, git } ;
120
119
120
+
121
+ info ! ( "matching on exa.run" ) ;
121
122
match exa. run ( ) {
122
123
Ok ( exit_status) => {
124
+ trace ! ( "exa.run: exit Ok(exit_status)" ) ;
123
125
exit ( exit_status) ;
124
126
}
125
127
@@ -130,6 +132,7 @@ fn main() {
130
132
131
133
Err ( e) => {
132
134
eprintln ! ( "{e}" ) ;
135
+ trace ! ( "exa.run: exit RUNTIME_ERROR" ) ;
133
136
exit ( exits:: RUNTIME_ERROR ) ;
134
137
}
135
138
}
@@ -225,8 +228,13 @@ impl<'args> Exa<'args> {
225
228
226
229
Ok ( f) => {
227
230
if f. points_to_directory ( ) && ! self . options . dir_action . treat_dirs_as_files ( ) {
231
+ trace ! ( "matching on to_dir" ) ;
228
232
match f. to_dir ( ) {
229
233
Ok ( d) => dirs. push ( d) ,
234
+ Err ( e) if e. kind ( ) == ErrorKind :: PermissionDenied => {
235
+ warn ! ( "Permission Denied: {e}" ) ;
236
+ exit ( exits:: PERMISSION_DENIED ) ;
237
+ } ,
230
238
Err ( e) => writeln ! ( io:: stderr( ) , "{file_path:?}: {e}" ) ?,
231
239
}
232
240
}
@@ -378,4 +386,7 @@ mod exits {
378
386
379
387
/// Exit code for when the command-line options are invalid.
380
388
pub const OPTIONS_ERROR : i32 = 3 ;
389
+
390
+ /// Exit code for missing file permissions
391
+ pub const PERMISSION_DENIED : i32 = 13 ;
381
392
}
0 commit comments