Skip to content

pr: allow character, block, and fifo devices as input#9946

Merged
sylvestre merged 6 commits into
uutils:mainfrom
SaathwikDasari:fix-pr-dev-zero
Jan 1, 2026
Merged

pr: allow character, block, and fifo devices as input#9946
sylvestre merged 6 commits into
uutils:mainfrom
SaathwikDasari:fix-pr-dev-zero

Conversation

@SaathwikDasari

Copy link
Copy Markdown
Contributor

Fixes #9935

Problem: Running pr on character devices (e.g., /dev/zero) or FIFOs triggers an unknown filetype error because the check was limited to regular files and symlinks.

Solution: Updated the match logic in src/uu/pr/src/pr.rs to accept is_char_device(), is_block_device(), and is_fifo() as valid inputs, matching GNU pr behavior.

Testing:

Manual: cargo run --bin coreutils -- pr /dev/zero now reads the stream instead of erroring.
cargo test --package uu_pr passed.

Style: Ran cargo fmt.

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/tty/tty-eof. tests/tty/tty-eof is passing on 'main'. Maybe you have to rebase?

@SaathwikDasari

Copy link
Copy Markdown
Contributor Author

All core logic is complete and I have verified the fix for /dev/zero locally.

I have also addressed the unused-mut warning for Windows to ensure cross-platform compatibility. Regarding the remaining CI failures:

  1. The Style/format failure was a network timeout during the 'Set up job' phase (fetching the toolchain).

  2. The tty-eof failure appears to be a known flaky test unrelated to the changes in pr.rs.

This PR is ready for review.

@sylvestre

Copy link
Copy Markdown
Contributor

please add a test to cover this change

Comment thread tests/by-util/test_pr.rs Outdated
new_ucmd!()
.arg("/dev/null")
.succeeds();
} No newline at end of file

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.

Suggested change
}
}

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@SaathwikDasari

Copy link
Copy Markdown
Contributor Author

All tests are passing and the output matches GNU behavior. Ready for review! @sylvestre

@sylvestre
sylvestre merged commit b600c25 into uutils:main Jan 1, 2026
129 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pr: /dev/zero: unknown filetype

2 participants