1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 05:27:45 +00:00

readlink: eliminate duplicate code

This commit is contained in:
Jeffrey Finkelstein 2021-12-29 14:42:00 -05:00
parent 4ae838a8b2
commit 2a7831bd94

View file

@ -78,18 +78,12 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
for f in &files { for f in &files {
let p = PathBuf::from(f); let p = PathBuf::from(f);
if res_mode == ResolveMode::None { let path_result = if res_mode == ResolveMode::None {
match fs::read_link(&p) { fs::read_link(&p)
Ok(path) => show(&path, no_newline, use_zero),
Err(err) => {
if verbose {
show_error!("{}: errno {}", f.maybe_quote(), err.raw_os_error().unwrap());
}
return 1;
}
}
} else { } else {
match canonicalize(&p, can_mode, res_mode) { canonicalize(&p, can_mode, res_mode)
};
match path_result {
Ok(path) => show(&path, no_newline, use_zero), Ok(path) => show(&path, no_newline, use_zero),
Err(err) => { Err(err) => {
if verbose { if verbose {
@ -99,7 +93,6 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
} }
} }
} }
}
0 0
} }