File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ struct Args {
3131 #[ arg( short = 'f' ) ]
3232 canonicalize : bool ,
3333
34+ /// Print an error description to standard error when an error occurs and the specified file could not be resolved
35+ #[ arg( short = 'v' ) ]
36+ verbose : bool ,
37+
3438 /// The pathname of an existing symbolic link
3539 pathname : PathBuf ,
3640}
@@ -42,13 +46,10 @@ struct Args {
4246// Behavior of "readlink -f /non-existent-directory/non-existent-file" does not vary
4347// All implementations: print nothing, exit code 1
4448fn do_readlink ( args : Args ) -> Result < String , String > {
45- // TODO
46- // Add --verbose option and mirror other implementations (which are quiet by default)?
47- let verbose = true ;
48-
4949 let Args {
5050 no_newline,
5151 canonicalize,
52+ verbose,
5253 pathname,
5354 } = args;
5455
@@ -185,11 +186,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
185186 0_i32
186187 }
187188 Err ( error_description) => {
188- let mut stderr_lock = stderr ( ) . lock ( ) ;
189+ if !error_description. is_empty ( ) {
190+ let mut stderr_lock = stderr ( ) . lock ( ) ;
189191
190- writeln ! ( & mut stderr_lock, "readlink: {error_description}" ) . unwrap ( ) ;
192+ writeln ! ( & mut stderr_lock, "readlink: {error_description}" ) . unwrap ( ) ;
191193
192- stderr_lock. flush ( ) . unwrap ( ) ;
194+ stderr_lock. flush ( ) . unwrap ( ) ;
195+ }
193196
194197 1_i32
195198 }
You can’t perform that action at this time.
0 commit comments