printenv: change exit code when variable not found
GNU printenv has this behavior
@@ -45,14 +45,21 @@ 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;
}
}
+ if not_found {
+ Err(1.into())
+ } else {
Ok(())
}
+}
pub fn uu_app() -> App<'static, 'static> {
App::new(uucore::util_name())
