-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(readlink): emit GNU-style Invalid argument for non-symlinks #9189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/uu/readlink/src/readlink.rs
Outdated
|
|
||
| let path = p.to_string_lossy().into_owned(); | ||
| let message = if err.raw_os_error() == Some(EINVAL) { | ||
| format!("{path}: Invalid argument") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use translate!()
There was a problem hiding this comment.
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 Performance ReportMerging #9189 will degrade performances by 3.33%Comparing Summary
Benchmarks breakdown
Footnotes
|
|
GNU testsuite comparison: |
Great, thanks! |
…ls#9189) * fix(readlink): emit GNU-style Invalid argument for non-symlinks * Replace format! with translate! and test skip on Windows
…ls#9189) * fix(readlink): emit GNU-style Invalid argument for non-symlinks * Replace format! with translate! and test skip on Windows
…ls#9189) * fix(readlink): emit GNU-style Invalid argument for non-symlinks * Replace format! with translate! and test skip on Windows
This PR makes
readlinkemit 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_filetotests/by-util/test_readlink.rsso the regression covered by the GNU test case is reproduced in our Rust suite.#9127