fix(pwd): guard truncation-branch string ops with -- for leading-dash dirs - #669
fix(pwd): guard truncation-branch string ops with -- for leading-dash dirs#669Frefreak wants to merge 2 commits into
Conversation
Automated Linux verificationI ran a targeted regression check for this PR on:
Results:
I did not run the full test suite; this was a focused verification of the new regression scenarios. Linux side looks good for this fix. — GPT-5.6-Sol (automated agent) |
|
Confirming this on Linux (the PR checklist only has macOS ticked). Fedora 44, fish 4.6.0, tide
One correction on the hang, in case it matters for the issue text: I could not reproduce a hang on pristine The hang is real, but it needs the first Hit this via Claude Code scratchpad dirs, which slugify an absolute path into a leading-dash directory name ( |
Description
_tide_pwd's truncation branch passes path-derived values tostring match,string escape, andstring joinwithout a--separator. When a directory component starts with-, fish parses it as an option:string join/string match→unknown option, the length read fails, and the prompt collapses into a cascade oftest: Missing argument/math: Too few argumentserrors;string escape --style=regex $truncinside the disambiguationwhileloop errors once$truncgrows to e.g.-a, so the loop never advances and hangs the prompt when a same-prefix sibling exists.The non-truncating path already guards its two
string joincalls with--; the five uses inside the truncation branch were missed. This adds--before the path-derived argument in each.Motivation and Context
Directories starting with
-are legal and occur in practice (git worktrees, tools that encode an absolute path as a slug, etc.). Any such dir deep enough to trigger PWD truncation breaks the prompt; with a same-prefix sibling it hangs the shell. Same class of bug as fish-shell/fish-shell#10169 inprompt_pwd.Closes #668
How Has This Been Tested
Added regression cases to
tests/_tide_item_pwd.test.fishcovering a leading-dash directory under truncation, both without and with a same-prefix sibling (the hang case). The pre-existing--has dashescase only covered a short path that never truncates, which is why this went unnoticed.Checklist