Skip to content

cmp: keep error messages when stdout is /dev/null - #374

Open
binhvq wants to merge 3 commits into
uutils:mainfrom
binhvq:cmp-dev-null-errors
Open

binhvq wants to merge 3 commits into
uutils:mainfrom
binhvq:cmp-dev-null-errors

Conversation

@binhvq

@binhvq binhvq commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #345.

When stdout is /dev/null, parse_params set quiet, which is also what -s sets and what hides error messages. So cmp a missing > /dev/null exited 2 with nothing on stderr, and cmp -l -s a b > /dev/null was accepted.

The redirect now has its own flag. It only skips the difference and EOF reports; errors are hidden by -s alone, and the -l/-s check runs first.

The test from the issue doesn't compile (assert_cmd::Command has no stdout()), so the new tests use std::process::Command like cmp_fast_paths.

The /dev/null optimisation turned on -s, which also hides error messages, so 'cmp a missing > /dev/null' exited 2 without saying why and 'cmp -l -s > /dev/null' no longer rejected the two options. Track the redirect separately and only skip the difference and EOF reports for it.
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.

cmp - stdout on /dev/null also silences error messages on stderr

1 participant