Skip to content

fix(completion): quoted ~ and $ stay literal in path prefixes - #1058

Merged
HalFrgrd merged 1 commit into
HalFrgrd:masterfrom
lenitain:fix/quoted-path-expansion
Nov 7, 2026
Merged

HalFrgrd merged 1 commit into
HalFrgrd:masterfrom
lenitain:fix/quoted-path-expansion

Conversation

@lenitain

@lenitain lenitain commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

fully_expand_path() dequoted the path before asking bash to expand it, so
quoted or escaped text became syntax again: "~", "a\$HOME", a'$HOME'
and x/'$HOME' expanded to $HOME or its value, and completion looked in the
wrong directory.

Pass the raw word to bash instead, and mirror that in TestBackend with a
quote-aware expander (tilde only at an unquoted word start, $ only unquoted
or in double quotes, quotes removed afterwards).

Tests

cargo test --lib (888 passed), fmt, clippy and rustdoc pass. New tests cover
quoted/escaped ~ and $, plus an end-to-end completion test with literal
~ and $HOME directories.

Manual check with the debug build: qutebrowser "~/" resolves to <cwd>/~,
qutebrowser $PWD/ still expands, and qutebrowser x/'$HOME'/ resolves to
<cwd>/x/$HOME.

fully_expand_path() dequoted the path before asking bash to expand it. That
turned quoted or escaped text into syntax again, so `"~"`, `"a\$HOME"`,
`a'$HOME'` and `x/'$HOME'` expanded to HOME or its value and completion looked
in the wrong directory.

Pass the raw word to bash instead: quoting decides what is literal and bash
removes the quotes itself. TestBackend mirrors that with a small quote-aware
expander so tests keep matching bash.

Add unit tests for quoted tilde and vars, plus an end-to-end completion test
with literal `~` and `$HOME` directories.

@HalFrgrd HalFrgrd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@HalFrgrd
HalFrgrd merged commit e3d402c into HalFrgrd:master Nov 7, 2026
1 check passed
@lenitain
lenitain deleted the fix/quoted-path-expansion branch November 8, 2026 02:22
@lenitain
lenitain restored the fix/quoted-path-expansion branch November 8, 2026 02:22
@lenitain
lenitain deleted the fix/quoted-path-expansion branch November 8, 2026 02:24
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.

2 participants