Skip to content

ln: add error handling for hard link creation on directories - #9342

Merged
cakebaker merged 4 commits into
uutils:mainfrom
FidelSch:ln-dir-hardlink
Nov 21, 2025
Merged

ln: add error handling for hard link creation on directories#9342
cakebaker merged 4 commits into
uutils:mainfrom
FidelSch:ln-dir-hardlink

Conversation

@FidelSch

Copy link
Copy Markdown
Contributor

Adresses #9333

@sylvestre

Copy link
Copy Markdown
Contributor

Lgtm (waiting for the ci now)

Comment thread tests/by-util/test_ln.rs Outdated
Comment on lines +945 to +951
let result = scene.ucmd().args(&["dir", "dir_link"]).fails();

assert!(
result
.stderr_str()
.contains("hard link not allowed for directory")
);

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.

A detail: you can simplify the code a bit by using stderr_contains:

Suggested change
let result = scene.ucmd().args(&["dir", "dir_link"]).fails();
assert!(
result
.stderr_str()
.contains("hard link not allowed for directory")
);
scene
.ucmd()
.args(&["dir", "dir_link"])
.fails()
.stderr_contains("hard link not allowed for directory");

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.

totally missed that, adding it now

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/ln/hard-to-sym. tests/ln/hard-to-sym is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

1 similar comment
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/ln/hard-to-sym. tests/ln/hard-to-sym is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/ln/hard-to-sym. tests/ln/hard-to-sym is passing on 'main'. Maybe you have to rebase?

@FidelSch

Copy link
Copy Markdown
Contributor Author

GNU tests seem to not pass still, even though I am mimicking the behaviour of my builtin ln.
Tests seem to expect a different error message. Maybe from a different coreutils version?

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/ln/hard-to-sym. tests/ln/hard-to-sym is passing on 'main'. Maybe you have to rebase?

@cakebaker

Copy link
Copy Markdown
Contributor

@FidelSch we replace the error message used in the GNU test in util/build-gnu.sh

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/fold/fold is no longer failing!

@cakebaker
cakebaker merged commit b5561e7 into uutils:main Nov 21, 2025
130 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

Thanks for your PR!

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.

ln's error message is less useful than GNU ln's when trying to create a hardlink to a directory

3 participants