Skip to content

Commit ed3e6b5

Browse files
uname: use UResult
1 parent 06f3db8 commit ed3e6b5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/uu/uname/src/uname.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010

1111
// spell-checker:ignore (ToDO) nodename kernelname kernelrelease kernelversion sysname hwplatform mnrsv
1212

13-
#[macro_use]
14-
extern crate uucore;
15-
1613
use clap::{crate_version, App, Arg};
1714
use platform_info::*;
15+
use uucore::error::{FromIo, UResult};
1816

1917
const ABOUT: &str = "Print certain system information. With no OPTION, same as -s.";
2018

@@ -49,11 +47,13 @@ const HOST_OS: &str = "Fuchsia";
4947
#[cfg(target_os = "redox")]
5048
const HOST_OS: &str = "Redox";
5149

52-
pub fn uumain(args: impl uucore::Args) -> i32 {
50+
#[uucore_procs::gen_uumain]
51+
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
5352
let usage = format!("{} [OPTION]...", uucore::execution_phrase());
5453
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
5554

56-
let uname = crash_if_err!(1, PlatformInfo::new());
55+
let uname =
56+
PlatformInfo::new().map_err_context(|| "failed to create PlatformInfo".to_string())?;
5757
let mut output = String::new();
5858

5959
let all = matches.is_present(options::ALL);
@@ -115,7 +115,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
115115
}
116116
println!("{}", output.trim_end());
117117

118-
0
118+
Ok(())
119119
}
120120

121121
pub fn uu_app() -> App<'static, 'static> {

0 commit comments

Comments
 (0)