Merge pull request #2830 from jfinkels/tee-uresult

tee: return UResult from uumain() function
This commit is contained in:
Sylvestre Ledru 2022-01-05 13:51:05 +01:00 committed by GitHub
commit 8ef2ea1356
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,6 +14,7 @@ use std::fs::OpenOptions;
use std::io::{copy, sink, stdin, stdout, Error, ErrorKind, Read, Result, Write};
use std::path::PathBuf;
use uucore::display::Quotable;
use uucore::error::UResult;
#[cfg(unix)]
use uucore::libc;
@ -37,7 +38,8 @@ fn usage() -> String {
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 matches = uu_app().usage(&usage[..]).get_matches_from(args);
@ -52,8 +54,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
};
match tee(options) {
Ok(_) => 0,
Err(_) => 1,
Ok(_) => Ok(()),
Err(_) => Err(1.into()),
}
}