Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/head/src/head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ fn uu_head(options: &HeadOptions) -> UResult<()> {
writeln!(stdout)?;
}
write!(stdout, "==> ")?;
print_verbatim(file).unwrap();
print_verbatim(file)?;
writeln!(stdout, " <==")?;
first = false;
}
Expand Down
23 changes: 23 additions & 0 deletions tests/by-util/test_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,29 @@ fn test_head_rejects_directory_through_symlink() {
/// Regression for #11972: a symlink that points to a regular file must
/// still be readable by head (the fd-based check must distinguish the
/// fd's mode, not the symlink's).
Comment on lines 1074 to 1076

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment got disconnected from test_head_follows_symlink_to_regular_file.

#[test]
#[cfg(target_os = "linux")]
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths (/dev) not visible")]
fn test_verbose_header_write_error_long_filename() {
use std::fs::File;

let dev_full =
File::create("/dev/full").expect("Failed to open /dev/full - test must run on Linux");

// A filename longer than the stdout buffer forces the header write to flush
// mid-write, so the failure surfaces inside the filename write rather than
// at the next checked one.
let long_path = format!("/dev/{}null", "./".repeat(512));

new_ucmd!()
.arg("-v")
.arg(long_path)
.set_stdout(dev_full)
.fails()
.code_is(1)
.stderr_contains("No space left on device");
}

#[test]
#[cfg(unix)]
fn test_head_follows_symlink_to_regular_file() {
Expand Down
Loading