Repository navigation
fix(realpath): resolve symlinks anywhere in the path - #2957
Conversation
realpath only cleaned . and .. lexically, so /l/c with /l -> /a/b printed /l/c. Share readlink -f's bounded symlink walk for operands and the --relative-to/--relative-base path; -s keeps lexical mode; loops report ELOOP; -e failures continue to the next operand like GNU.
Review verdict: approve direction, fix
|
--relative-to prints ../-style relative paths; --relative-base prints paths under DIR relative and others absolute, and turns --relative-to off when DIR is outside it. -q silences a base loop error. Fix stale doc.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | c04e096 | Commit Preview URL Branch Preview URL |
Nov 19 2026, 06:10 PM |
Requested by Михайло · project thread
What changed
realpathnow resolves symlinks anywhere in the path, using the same bounded walk asreadlink -f(40-hop cap, path limits). The--relative-to/--relative-basepaths are resolved the same way, and both now follow GNU:--relative-toprints..-style paths (--relative-to=/a /b/cgives../b/c, was/b/c), and--relative-basekeeps paths outside DIR absolute.-skeeps the old lexical-only behavior.realpath: X: Too many levels of symbolic linksand exits 1.-eon a missing path reports the operand as given and moves on to the next one, like GNU (it used to stop at the first failure).Why
realpathonly cleaned.and.., so scripts that use it to find a script's real location or to compare paths got the symlinked path back. I found it while writing the #2933 separator tests.Before / After
With
/l -> /a/b:New spec case
realpath_follows_intermediate_symlinkcovers plain,-s,-e,--relative-toand cwd-inside-a-symlink cases. Its expected output matches real bash 5 / GNU coreutils. 7 new unit tests (the relative cases use GNUrealpath -moutput as expected values). Libpath::33 pass, integration 1932 pass.Risk
-E=-mhere).Checklist
Generated by Claude Code