mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
printenv: change exit code when variable not found
GNU printenv has this behavior
This commit is contained in:
parent
f2a3a1f920
commit
b157a73a1f
1 changed files with 8 additions and 1 deletions
|
@ -45,13 +45,20 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut not_found = false;
|
||||||
for env_var in variables {
|
for env_var in variables {
|
||||||
if let Ok(var) = env::var(env_var) {
|
if let Ok(var) = env::var(env_var) {
|
||||||
print!("{}{}", var, separator);
|
print!("{}{}", var, separator);
|
||||||
|
} else {
|
||||||
|
not_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
if not_found {
|
||||||
|
Err(1.into())
|
||||||
|
} else {
|
||||||
|
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