Skip to content

ln: keep the destination when a forced link fails - #14574

Merged
cakebaker merged 1 commit into
uutils:mainfrom
nagendramohan:fix/ln-force-keep-dest-14550
Sep 15, 2026
Merged

cakebaker merged 1 commit into
uutils:mainfrom
nagendramohan:fix/ln-force-keep-dest-14550

Conversation

@nagendramohan

Copy link
Copy Markdown
Contributor

ln -f A B unlinked B before attempting the link, so a link that failed for any reason other than the destination already existing (a missing source, a directory source, a dangling symlink with -L) left B deleted.

Attempt the link first and remove an existing destination only after the link reports EEXIST, matching GNU, so a failed link never destroys the destination.

Fixes #14550

`ln -f A B` unlinked B before attempting the link, so a link that failed
for any reason other than the destination already existing (a missing
source, a directory source, a dangling symlink with -L) left B deleted.

Attempt the link first and remove an existing destination only after the
link reports EEXIST, matching GNU, so a failed link never destroys the
destination.

Fixes uutils#14550

Signed-off-by: nagendramohan <nagendramohan1990@gmail.com>
@nagendramohan
nagendramohan force-pushed the fix/ln-force-keep-dest-14550 branch from 9e25827 to d30afbd Compare September 15, 2026 06:42
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/misc/io-errors (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/symlink (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/cut/bounded-memory is now being skipped but was previously passing.

@cakebaker
cakebaker merged commit c6b9e4f into uutils:main Sep 15, 2026
101 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

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.

ln -f removes the destination before attempting the link, so a failed link destroys it

2 participants