Repository navigation
cat: distinguish read and write errors - #14721
Conversation
| PipeError::Read(error) | PipeError::Write(error) => error, | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
This is currently unwrapping Read,Write for other utils. But we should distinct at all utils and remove this impl in the future. This is why we should https://github.com/uutils/coreutils/pull/14721/changes#r4053088325 .
|
GNU testsuite comparison: |
565e17e to
8fa139c
Compare
| #[error("{}", strip_errno(.0))] | ||
| Io(#[from] io::Error), | ||
| #[error("{}: {}", translate!("common-write-error"), strip_errno(.0))] | ||
| Write(io::Error), |
There was a problem hiding this comment.
Can we directly put uucore::io::DistinguishedIOError::Write at here?
There was a problem hiding this comment.
uucore::io::DistinguishedIOError does not yet exist, let's fix the test and refactor later.
Merging this PR will regress 1 benchmark
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | three_39_bit_primes |
591.3 ms | 686 ms | -13.8% |
| ⚡ | Simulation | five_38_bit_primes |
2.1 s | 1.5 s | +34.85% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing wtcpython:cat-distinct-err (e5c769e) with main (01a8fc0)
Footnotes
-
54 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
8fa139c to
405d6de
Compare
405d6de to
48dbdc3
Compare
48dbdc3 to
6542e27
Compare
6542e27 to
cbe8aa8
Compare
cbe8aa8 to
72cb3a1
Compare
72cb3a1 to
f768ec0
Compare
f768ec0 to
8584175
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 2
| Read(std::io::Error), | ||
| Write(std::io::Error), | ||
| } | ||
|
|
| if drain_pipe(pipe_rd, dest, n) | ||
| .map_err(PipeError::Write)? | ||
| .is_err() | ||
| { |
| .ignore_stdin_write_error() | ||
| .fails() | ||
| .stderr_contains("No space left on device"); | ||
| .stderr_is("cat: write error: No space left on device\n"); |
8584175 to
14c2fae
Compare
14c2fae to
593b543
Compare
| if let Err(err) = cat_path(path, options, &mut state) { | ||
| error_messages.push(format!("{}: {err}", path.maybe_quote())); | ||
| let is_write_error = matches!(&err, CatError::Write(_)); | ||
| error_messages.push(match &err { |
There was a problem hiding this comment.
could be simpler, no? if let CatError::Write(_) = err { error_messages.push(err.to_string()); break; } and keep the old push otherwise
| .inspect_err(handle_broken_pipe)?; | ||
| .inspect_err(handle_broken_pipe) | ||
| .map_err(CatError::Write)?; | ||
| // cannot use rustix::io on Windows |
There was a problem hiding this comment.
what about print_lines? cat -n - /dev/zero > /dev/full still goes through Io, so it gets the -: prefix and doesn't stop
please handle it too and add a test with -n
| } | ||
|
|
||
| type PipeRes = std::io::Result<Result<(), ()>>; | ||
| type SpliceRes = Result<Result<(), ()>, PipeError>; |
There was a problem hiding this comment.
the doc explaining the Ok(Ok)/Ok(Err)/Err meaning was removed, could you please keep it on SpliceRes?
593b543 to
15d1a3d
Compare
15d1a3d to
985d7b9
Compare
985d7b9 to
e5c769e
Compare
Great, thanks! |


Should make test cat/cat-distinct-err.sh pass