* fix(comm): improve stdout handling and add test for lossy UTF-8 output
* run cargo fmt
* perf(comm): use BufWriter for buffered stdout output
Wrap stdout in BufWriter to improve performance and avoid
duplicate error messages, matching GNU comm behavior.
* fix: refactor write operations in comm to use a dedicated function
* comm: use translate!
---------
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
* comm: fix comparison when reading from pipes
Use case is that two files are piped into comm, i.e. in bash
comm <(cat file1) <(cat file2)
Before the fix, comm reads from the pipes twice. Once in "fn comm" and
once in "fn are_files_identical". As such, part of the data is skipped
in comparison which leads to wrong output.
This is fixed by skipping the file comparison in case one of the files
is not a regular file.
* comm: add test for reading from pipes
* fix: handle EINTR (signal interruptions) in cat, od, and comm
Add proper retry loops for ErrorKind::Interrupted in I/O operations
to handle signals like SIGUSR1 that can interrupt read/write calls.
This pattern is proven in production - identical to PR #6025 (merged
March 2024) which fixed dd's EINTR handling for GNU test dd/stats.sh.
The same pattern is already used in 9+ utilities (head, tail, tee, wc,
sort, sum, tr, shuf, dd) without issues.
Changes:
- cat: Fix write_fast() and write_lines() to retry on EINTR
- od: Fix PartialReader::read() in all three read paths
- comm: Fix are_files_identical() for both file readers
- tests: Add InterruptingReader/Writer test utilities
Historical context:
- Pattern validated by cre4ture's PR #6025 (dd EINTR fix)
- Matches existing implementations in dd/dd.rs:450,881
- POSIX best practice for signal-interrupted I/O
Fixes#1275
* fix: handle EINTR (signal interruptions) in cat, od, and comm
Add proper retry loops for ErrorKind::Interrupted in I/O operations to handle signals like SIGUSR1 that can interrupt read/write calls.
Pattern matches PR #6025 (dd EINTR fix) and is already used in 9+ utilities. Changes:
- cat: Fix write_fast() and write_lines() to retry on EINTR
- od: Fix PartialReader::read() in all three read paths
- comm: Fix are_files_identical() for both file readers
- tests: Add visible EINTR integration tests for CI
Addresses sylvestre's review feedback on code documentation and CI test visibility.
* style: apply cargo fmt formatting to EINTR changes
* test: fix EINTR integration test failures
- Fix comm test: use stdout_contains instead of stdout_only for tabbed output
- Fix od test: create new command instance to avoid 'already run this UCommand' error
- Remove unused imports and dead code to eliminate compiler warnings
- Both tests now pass without warnings or errors
* style: fix formatting and remove duplicate comment in od test
* ci: add EINTR and related technical terms to appropriate cspell dictionaries
- Add EINTR, eintr, nextest to jargon.wordlist.txt (technical/systems programming terms)
- Add SIGUSR, SIGINT, etc. to shell.wordlist.txt (POSIX signals)
- Add uutils, coreutils, ucmd, etc. to workspace.wordlist.txt (project-specific terms)
- Fixes CI cspell warnings for legitimate technical terminology
- Proper categorization follows existing dictionary structure
A few comments:
* skip if the two args are pointing to the same file
* skip if the same content in the two files
* implement --check-order
* implement --nocheck-order
* output the right things on stderr
Should pass: tests/misc/comm