mirror of
https://github.com/uutils/coreutils
synced 2024-11-17 18:28:18 +00:00
printenv: use UResult
This commit is contained in:
parent
a05628f018
commit
f2a3a1f920
1 changed files with 6 additions and 3 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
use clap::{crate_version, App, Arg};
|
||||
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.";
|
||||
|
||||
|
@ -20,7 +21,8 @@ fn usage() -> String {
|
|||
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 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() {
|
||||
print!("{}={}{}", env_var, value, separator);
|
||||
}
|
||||
return 0;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
for env_var in variables {
|
||||
|
@ -48,7 +50,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
|||
print!("{}{}", var, separator);
|
||||
}
|
||||
}
|
||||
0
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn uu_app() -> App<'static, 'static> {
|
||||
|
|
Loading…
Reference in a new issue