Repository navigation
xargs: strip (os error N) from --arg-file open failure - #822
Conversation
When --arg-file points at a missing path, xargs used to surface the raw
io::Error display, which appends " (os error N)" for OS errors:
Error: Failed to open sdf: No such file or directory (os error 2)
GNU xargs omits that detail. Reuse uucore::error::strip_errno (already
used by updatedb) so the message reads:
Error: Failed to open sdf: No such file or directory
Closes uutils#811
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #822 +/- ##
=======================================
Coverage 91.93% 91.93%
=======================================
Files 35 35
Lines 7251 7253 +2
Branches 378 378
=======================================
+ Hits 6666 6668 +2
Misses 443 443
Partials 142 142 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Commit 6fdc755 has test result changes: bfs testsuite: |
|
Fails on windows: |
The assertion hardcoded the Unix errno wording ("No such file or
directory"), so the test failed on Windows where the OS reports
"The system cannot find the path specified." (reported by @sylvestre).
The contract this test guards is only that the trailing "(os error N)"
suffix is stripped — the OS wording is out of our control. Assert the
portable parts instead: our "Failed to open <path>:" wrapper names the
path and no "(os error" suffix leaks.
|
Thanks @sylvestre — good catch. Pushed a fix (b8fd422): the test hardcoded the Unix errno wording Separately, the compat (BFS) job flags |
|
@MsfPablo please answering through your llm |
|
Commit b8fd422 has test result changes: bfs testsuite: |
Summary
When
--arg-filepoints at a missing path,xargsused to surface the rawio::Errordisplay, which appends(os error N)for OS errors:GNU
xargsomits that detail. This reusesuucore::error::strip_errno— the same helperupdatedbalready uses for the identical "strip the trailing(os error N)so the message reads cleanly" goal — so the output becomes:This is a one-line change at the arg-file open site plus the existing helper; no new abstraction.
Closes #811.
Test plan
xargs_arg_file_missing_strips_errnointegration test asserting: exit code 1, stderr containsFailed to open, containsNo such file or directory, and does not contain(os error.cargo test— full workspace suite green (find, locate, updatedb, xargs: 28/28 + doctests).cargo fmt --checkclean.cargo clippy --bin xargsclean.(os error N)suffix is gone.Context
I went with
strip_errnorather than a custom regex becauseupdatedb/mod.rsalready established it as the codebase pattern for exactly this (strip the trailing "(os error N)" ...). Happy to change the wording (e.g. GNU-stylexargs: sdf: No such file or directory) if maintainers prefer a closer GNU message match — kept it minimal here since #811 only asks to drop the(os error N).This contribution was developed with AI assistance (Claude). I have reviewed and understand every line of the diff.