mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
realpath: return UResult from uumain() function
This commit is contained in:
parent
cd1a0fbe36
commit
49dca9adcb
1 changed files with 11 additions and 9 deletions
|
@ -17,6 +17,7 @@ use std::{
|
||||||
};
|
};
|
||||||
use uucore::{
|
use uucore::{
|
||||||
display::{print_verbatim, Quotable},
|
display::{print_verbatim, Quotable},
|
||||||
|
error::{FromIo, UResult},
|
||||||
fs::{canonicalize, MissingHandling, ResolveMode},
|
fs::{canonicalize, MissingHandling, ResolveMode},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,7 +37,8 @@ fn usage() -> String {
|
||||||
format!("{0} [OPTION]... FILE...", uucore::execution_phrase())
|
format!("{0} [OPTION]... FILE...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
#[uucore_procs::gen_uumain]
|
||||||
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let usage = usage();
|
let usage = usage();
|
||||||
|
|
||||||
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
|
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
|
||||||
|
@ -60,16 +62,16 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
} else {
|
} else {
|
||||||
MissingHandling::Normal
|
MissingHandling::Normal
|
||||||
};
|
};
|
||||||
let mut retcode = 0;
|
|
||||||
for path in &paths {
|
for path in &paths {
|
||||||
if let Err(e) = resolve_path(path, strip, zero, logical, can_mode) {
|
let result = resolve_path(path, strip, zero, logical, can_mode);
|
||||||
if !quiet {
|
if !quiet {
|
||||||
show_error!("{}: {}", path.maybe_quote(), e);
|
show_if_err!(result.map_err_context(|| path.maybe_quote().to_string()));
|
||||||
}
|
}
|
||||||
retcode = 1
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
retcode
|
// Although we return `Ok`, it is possible that a call to
|
||||||
|
// `show!()` above has set the exit code for the program to a
|
||||||
|
// non-zero integer.
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue