Skip to content

cmp: honor the byte limit in quiet size checks - #296

Open
SichenLiang wants to merge 1 commit into
uutils:mainfrom
SichenLiang:cmp-quiet-byte-limit
Open

SichenLiang wants to merge 1 commit into
uutils:mainfrom
SichenLiang:cmp-quiet-byte-limit

Conversation

@SichenLiang

Copy link
Copy Markdown

Use the quiet-mode size shortcut only for two regular files, with no skipped bytes, when the comparison limit extends beyond the shorter file. Otherwise, read the requested data as needed before deciding the result.

This fixes byte-limited comparisons and gives GNU-compatible status in the tested directory and /dev/zero cases. One difference remains: cmp -s a dir now returns 2, but quiet mode still omits GNU's Is a directory diagnostic.

New tests cover byte limits, skipped bytes, devices, directories, and -i 0.

Fixes #295

Use the quiet-mode size shortcut only for two regular files, with no
skipped bytes, when the comparison limit extends beyond the shorter
file. Otherwise, read the requested data as needed before deciding the
result.

This fixes byte-limited comparisons and gives GNU-compatible status in
the tested directory and /dev/zero cases. One difference remains:
`cmp -s a dir` now returns 2, but quiet mode still omits GNU's
"Is a directory" diagnostic.

New tests cover byte limits, skipped bytes, devices, directories, and
`-i 0`.
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: quiet mode compares full file sizes before applying -n

1 participant