Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@karanabe
Copy link
Contributor

@karanabe karanabe commented Nov 8, 2025

This PR makes readlink emit the same “: Invalid argument” diagnostic that GNU prints when a non-symlink operand is rejected (GNU exercises this path by setting POSIXLY_CORRECT). We now detect EINVAL from read_link/canonicalize and force that message unless the user explicitly requested silent output; other IO errors still go through the existing context machinery.

I also added test_posixly_correct_regular_file to tests/by-util/test_readlink.rs so the regression covered by the GNU test case is reproduced in our Rust suite.

#9127


let path = p.to_string_lossy().into_owned();
let message = if err.raw_os_error() == Some(EINVAL) {
format!("{path}: Invalid argument")
Copy link
Contributor

Choose a reason for hiding this comment

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

please use translate!()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching that! I've updated it to use translate!().

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 8, 2025

CodSpeed Performance Report

Merging #9189 will degrade performances by 3.33%

Comparing karanabe:test/fix-readlink-posix (ce21dff) with main (714a72e)

Summary

❌ 1 regression
✅ 122 untouched
⏩ 2 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
du_human_balanced_tree[(5, 4, 10)] 10.2 ms 10.5 ms -3.33%

Footnotes

  1. 2 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.

@github-actions
Copy link

github-actions bot commented Nov 8, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/readlink/readlink-posix is no longer failing!

@cakebaker cakebaker merged commit 690405d into uutils:main Nov 8, 2025
121 of 122 checks passed
@cakebaker
Copy link
Contributor

Congrats! The gnu test tests/readlink/readlink-posix is no longer failing!

Great, thanks!

asder8215 pushed a commit to asder8215/coreutils that referenced this pull request Nov 8, 2025
…ls#9189)

* fix(readlink): emit GNU-style Invalid argument for non-symlinks

* Replace format! with translate! and test skip on Windows
naoNao89 pushed a commit to naoNao89/coreutils that referenced this pull request Nov 8, 2025
…ls#9189)

* fix(readlink): emit GNU-style Invalid argument for non-symlinks

* Replace format! with translate! and test skip on Windows
naoNao89 pushed a commit to naoNao89/coreutils that referenced this pull request Nov 9, 2025
…ls#9189)

* fix(readlink): emit GNU-style Invalid argument for non-symlinks

* Replace format! with translate! and test skip on Windows
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.

3 participants