Skip to content

Id: don't panic on write error#10769

Merged
ChrisDryden merged 8 commits intouutils:mainfrom
FidelSch:id-panic-on-write
Feb 6, 2026
Merged

Id: don't panic on write error#10769
ChrisDryden merged 8 commits intouutils:mainfrom
FidelSch:id-panic-on-write

Conversation

@FidelSch
Copy link
Copy Markdown
Contributor

@FidelSch FidelSch commented Feb 6, 2026

fixes #10561

As many functions now return Result<()> instead of (), also got rid of some unwrap()s where possible.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 6, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/usage_vs_getopt (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/shuf/shuf-reservoir (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/sort/sort-stale-thread-mem (passes in this run but fails in the 'main' branch)

#[allow(clippy::cognitive_complexity)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;
let mut lock = io::stdout().lock();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm taking a first read through and everything seems right, I need to do some more local testing because I am realizing I don't on a deep level understand what would be better, locking it at the beginning of locking it for each write

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So negligible measured perf differences, in theory on write heavy utilities this could have performance implications so this would be the right approach. We just have to be careful on multi-threaded utilities

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand from this, "The print! macro will lock the standard output on each call. If you call print! within a hot loop, this behavior may be the bottleneck of the loop. To avoid this, lock stdout with io::stdout().lock()", locking and unlocking seems to incur some overhead, that's why I opted to lock once.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or running many utils at same terminal?

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 6, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/usage_vs_getopt (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/shuf/shuf-reservoir (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/sort/sort-stale-thread-mem (passes in this run but fails in the 'main' branch)

@ChrisDryden
Copy link
Copy Markdown
Collaborator

Just waiting for the build to finish, the other CI failures are unrelated

@ChrisDryden ChrisDryden merged commit 0a28d65 into uutils:main Feb 6, 2026
152 of 155 checks passed
@ChrisDryden
Copy link
Copy Markdown
Collaborator

Thanks!

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.

id > /dev/full panics

3 participants