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:
parent
4ae838a8b2
commit
2a7831bd94
1 changed files with 10 additions and 17 deletions
|
@ -78,25 +78,18 @@ 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)
|
||||||
Ok(path) => show(&path, no_newline, use_zero),
|
};
|
||||||
Err(err) => {
|
match path_result {
|
||||||
if verbose {
|
Ok(path) => show(&path, no_newline, use_zero),
|
||||||
show_error!("{}: errno {}", f.maybe_quote(), err.raw_os_error().unwrap());
|
Err(err) => {
|
||||||
}
|
if verbose {
|
||||||
return 1;
|
show_error!("{}: errno {}", f.maybe_quote(), err.raw_os_error().unwrap());
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue