diff --git a/src/uu/users/src/users.rs b/src/uu/users/src/users.rs index 3fb48a9b613..6586c879f8b 100644 --- a/src/uu/users/src/users.rs +++ b/src/uu/users/src/users.rs @@ -6,6 +6,7 @@ // spell-checker:ignore (paths) wtmp use std::ffi::OsString; +use std::io::{Write, stdout}; use std::path::Path; use clap::builder::ValueParser; @@ -73,7 +74,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { if !users.is_empty() { users.sort(); - println!("{}", users.join(" ")); + writeln!(stdout().lock(), "{}", users.join(" "))?; } Ok(()) diff --git a/tests/by-util/test_users.rs b/tests/by-util/test_users.rs index 0d3d7772b83..dd1e043dacf 100644 --- a/tests/by-util/test_users.rs +++ b/tests/by-util/test_users.rs @@ -6,6 +6,21 @@ use uutests::new_ucmd; #[cfg(any(target_vendor = "apple", target_os = "linux"))] use uutests::{util::TestScenario, util_name}; +#[ignore = "does not work as same as users > /dev/full"] +#[test] +#[cfg(target_os = "linux")] +fn test_full_panic() { + let full = std::fs::OpenOptions::new() + .write(true) + .open("/dev/full") + .unwrap(); + + new_ucmd!() + .set_stdout(full) + .fails() + .stderr_contains("No space"); +} + #[test] fn test_invalid_arg() { new_ucmd!().arg("--definitely-invalid").fails_with_code(1);