Skip to content

fix(pwd): guard truncation-branch string ops with -- for leading-dash dirs - #669

Open
Frefreak wants to merge 1 commit into
IlanCosman:mainfrom
Frefreak:fix/pwd-leading-dash-truncation
Open

fix(pwd): guard truncation-branch string ops with -- for leading-dash dirs#669
Frefreak wants to merge 1 commit into
IlanCosman:mainfrom
Frefreak:fix/pwd-leading-dash-truncation

Conversation

@Frefreak

Copy link
Copy Markdown

Description

_tide_pwd's truncation branch passes path-derived values to string match, string escape, and string join without a -- separator. When a directory component starts with -, fish parses it as an option:

  • string join / string matchunknown option, the length read fails, and the prompt collapses into a cascade of test: Missing argument / math: Too few arguments errors;
  • worse, string escape --style=regex $trunc inside the disambiguation while loop errors once $trunc grows 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 join calls 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 in prompt_pwd.

Closes #668

How Has This Been Tested

Added regression cases to tests/_tide_item_pwd.test.fish covering a leading-dash directory under truncation, both without and with a same-prefix sibling (the hang case). The pre-existing --has dashes case only covered a short path that never truncates, which is why this went unnoticed.

  • I have tested using Linux.
  • I have tested using MacOS.

Checklist

  • I am ready to update the wiki accordingly.
  • I have updated the tests accordingly.

@Frefreak
Frefreak requested a review from IlanCosman as a code owner July 27, 2026 07:53
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.

Prompt breaks (and can hang) in dash-leading directories when path truncates

1 participant