mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
printenv: change exit code when variable not found
GNU printenv has this behavior
This commit is contained in:
@@ -45,13 +45,20 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let mut not_found = false;
|
||||
for env_var in variables {
|
||||
if let Ok(var) = env::var(env_var) {
|
||||
print!("{}{}", var, separator);
|
||||
} else {
|
||||
not_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
if not_found {
|
||||
Err(1.into())
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn uu_app() -> App<'static, 'static> {
|
||||
|
||||
Reference in New Issue
Block a user