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:
parent
a05628f018
commit
f2a3a1f920
1 changed files with 6 additions and 3 deletions
|
@ -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> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue