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

printenv: change exit code when variable not found

GNU printenv has this behavior
This commit is contained in:
Thomas Queiroz 2021-10-29 20:27:06 -03:00
parent f2a3a1f920
commit b157a73a1f
No known key found for this signature in database
GPG key ID: 229D2DDF7ECA5F8F

View file

@ -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> {