diff --git a/src/uu/chgrp/src/chgrp.rs b/src/uu/chgrp/src/chgrp.rs index d351eb2bb..dd851c504 100644 --- a/src/uu/chgrp/src/chgrp.rs +++ b/src/uu/chgrp/src/chgrp.rs @@ -363,7 +363,9 @@ impl Chgrper { self.verbosity.clone(), ) { Ok(n) => { - show_error!("{}", n); + if !n.is_empty() { + show_error!("{}", n); + } 0 } Err(e) => { diff --git a/tests/by-util/test_chgrp.rs b/tests/by-util/test_chgrp.rs index e887f659d..1b8057e47 100644 --- a/tests/by-util/test_chgrp.rs +++ b/tests/by-util/test_chgrp.rs @@ -229,6 +229,22 @@ fn test_big_h() { } } +#[test] +#[cfg(target_os = "linux")] +fn basic_succeeds() { + let (at, mut ucmd) = at_and_ucmd!(); + let one_group = nix::unistd::getgroups().unwrap(); + // if there are no groups we can't run this test. + if let Some(group) = one_group.first() { + at.touch("f1"); + ucmd.arg(group.as_raw().to_string()) + .arg("f1") + .succeeds() + .no_stdout() + .no_stderr(); + } +} + #[test] fn test_no_change() { let (at, mut ucmd) = at_and_ucmd!();