Skip to content

ln: don't panic on --relative with a parentless target#12631

Open
leeewee wants to merge 1 commit into
uutils:mainfrom
leeewee:ln-fix-relative-parentless-target
Open

ln: don't panic on --relative with a parentless target#12631
leeewee wants to merge 1 commit into
uutils:mainfrom
leeewee:ln-fix-relative-parentless-target

Conversation

@leeewee
Copy link
Copy Markdown
Contributor

@leeewee leeewee commented Jun 5, 2026

Fixes #12628

ln -rsfT SRC / (and … "") aborted with an Option::unwrap() panic before any filesystem operation: relative_path computed the destination's parent with dst.parent().unwrap(), but Path::parent() is None for a parentless destination (/, "", or a bare Windows prefix).

Fold dst.parent() into the guard and fall through to the non-relative src when it's None, so the caller reports the usual error (exit 1) instead of crashing. Adds a regression test.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/tail/pipe-f is now passing!
Skip an intermittent issue tests/pr/bounded-memory (was skipped on 'main', now failing)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jun 5, 2026

Merging this PR will not alter performance

✅ 323 untouched benchmarks
⏩ 46 skipped benchmarks1


Comparing leeewee:ln-fix-relative-parentless-target (0bae620) with main (abcdcdc)

Open in CodSpeed

Footnotes

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

`ln -rsfT SRC /` (and `… ""`) aborted with an Option::unwrap panic before any
filesystem operation: relative_path computed the destination's parent with
`dst.parent().unwrap()`, but Path::parent() is None for a parentless
destination (`/`, `""`, or a bare Windows prefix).

Match `dst.parent()` as part of the guard and fall through to the non-relative
`src` when it is None, so the caller reports the usual error (exit 1) instead
of crashing.
@leeewee leeewee force-pushed the ln-fix-relative-parentless-target branch from 439fca7 to 0bae620 Compare June 5, 2026 10:27
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 panics (unwrap None) on -r with a parentless target (/)

1 participant