fix(pwd): guard truncation-branch string ops with -- for leading-dash dirs - #669
Open
Frefreak wants to merge 1 commit into
Open
fix(pwd): guard truncation-branch string ops with -- for leading-dash dirs#669Frefreak wants to merge 1 commit into
Frefreak wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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