1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 13:07:46 +00:00

printenv: use UResult

This commit is contained in:
Thomas Queiroz 2021-10-29 20:25:41 -03:00
parent a05628f018
commit f2a3a1f920
No known key found for this signature in database
GPG key ID: 229D2DDF7ECA5F8F

View file

@ -9,6 +9,7 @@
use clap::{crate_version, App, Arg}; use clap::{crate_version, App, Arg};
use std::env; use std::env;
use uucore::error::UResult;
static ABOUT: &str = "Display the values of the specified environment VARIABLE(s), or (with no VARIABLE) display name and value pairs for them all."; static ABOUT: &str = "Display the values of the specified environment VARIABLE(s), or (with no VARIABLE) display name and value pairs for them all.";
@ -20,7 +21,8 @@ fn usage() -> String {
format!("{0} [VARIABLE]... [OPTION]...", uucore::execution_phrase()) format!("{0} [VARIABLE]... [OPTION]...", 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);
@ -40,7 +42,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
for (env_var, value) in env::vars() { for (env_var, value) in env::vars() {
print!("{}={}{}", env_var, value, separator); print!("{}={}{}", env_var, value, separator);
} }
return 0; return Ok(());
} }
for env_var in variables { for env_var in variables {
@ -48,7 +50,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
print!("{}{}", var, separator); print!("{}{}", var, separator);
} }
} }
0
Ok(())
} }
pub fn uu_app() -> App<'static, 'static> { pub fn uu_app() -> App<'static, 'static> {