Skip to content

tar: support -f - for stdin/stdout archives#156

Merged
sylvestre merged 3 commits into
uutils:mainfrom
kaladron:dashfdash
Jun 8, 2026
Merged

tar: support -f - for stdin/stdout archives#156
sylvestre merged 3 commits into
uutils:mainfrom
kaladron:dashfdash

Conversation

@kaladron

@kaladron kaladron commented Apr 4, 2026

Copy link
Copy Markdown
Collaborator

When the archive path is "-", read archives from stdin for list and extract, and write archive data to stdout for create.

Route create status output to stderr when writing the archive to stdout so verbose output does not corrupt the stream. Add CLI tests for create-to-stdout, list-from-stdin, extract-from-stdin, and the stderr routing cases.

@codecov

codecov Bot commented Apr 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.12230% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.78%. Comparing base (b4865da) to head (cef2373).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
tests/by-util/test_tar.rs 96.10% 3 Missing ⚠️
src/uu/tar/src/tar.rs 96.96% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
+ Coverage   96.59%   96.78%   +0.18%     
==========================================
  Files           9        9              
  Lines         941     1121     +180     
  Branches       24       28       +4     
==========================================
+ Hits          909     1085     +176     
- Misses         31       35       +4     
  Partials        1        1              
Flag Coverage Δ
macos_latest 96.78% <97.12%> (+0.18%) ⬆️
ubuntu_latest 96.78% <97.12%> (+0.18%) ⬆️
windows_latest 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/uu/tar/src/tar.rs Outdated
@sylvestre

Copy link
Copy Markdown
Contributor

GNU tar refuses -cf - when stdout is a tty (to avoid spewing binary). Maybe add aIsTerminal::is_terminal check and erroring out ?

@kaladron

kaladron commented Apr 5, 2026

Copy link
Copy Markdown
Collaborator Author

GNU tar refuses -cf - when stdout is a tty (to avoid spewing binary). Maybe add aIsTerminal::is_terminal check and erroring out ?

Fair point, I'll add that.

I'll need a few days to learn more about Rust's locking, though! =)

@sylvestre

Copy link
Copy Markdown
Contributor

ping ? :)

@sylvestre

Copy link
Copy Markdown
Contributor

needs to be rebased, sorry

@kaladron

Copy link
Copy Markdown
Collaborator Author

@sylvestre I was actually just trying to find the other PR I'd sent you - for this I was trying to figure out how the buffering ought to work. I haven't played a lot with efficient stdio in Rust yet. There are a bunch of other places where this could potentially apply.

And I swear I sent you a PR for those with a question and I'm not finding it.

@sylvestre

Copy link
Copy Markdown
Contributor

no worries :)

@kaladron kaladron force-pushed the dashfdash branch 2 times, most recently from 31a23d9 to 05328b1 Compare June 7, 2026 08:32
@kaladron kaladron marked this pull request as draft June 7, 2026 09:19
When the archive path is "-", read archives from stdin for list and
extract, and write archive data to stdout for create.

Route create status output to stderr when writing the archive to
stdout so verbose output does not corrupt the stream. Add CLI tests
for create-to-stdout, list-from-stdin, extract-from-stdin, and the
stderr routing cases.
@codspeed-hq

codspeed-hq Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 19.86%

⚡ 2 improved benchmarks
✅ 5 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
create_archive_100_files 504.9 µs 406.7 µs +24.14%
create_archive_10_files 64.8 µs 56 µs +15.73%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing kaladron:dashfdash (cef2373) with main (3eb916a)

Open in CodSpeed

@kaladron kaladron marked this pull request as ready for review June 7, 2026 11:54
@kaladron kaladron requested a review from sylvestre June 7, 2026 11:54
@kaladron

kaladron commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @sylvestre! Sorry about the delay. Your comments caused me to rework it a bit and I think I'm happy with the patch now. I appreciate any feedback you have.

@sylvestre sylvestre merged commit 25f4bd7 into uutils:main Jun 8, 2026
19 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

well done!

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.

2 participants