Skip to content

fix(interpreter): treat invalid glob bracket expressions as literals#845

Merged
chaliy merged 1 commit intomainfrom
fix/issue-837-glob-brackets
Mar 26, 2026
Merged

fix(interpreter): treat invalid glob bracket expressions as literals#845
chaliy merged 1 commit intomainfrom
fix/issue-837-glob-brackets

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Mar 26, 2026

Summary

  • Invalid bracket expressions (like []) in glob patterns are now treated as literal characters instead of failing to match
  • When match_bracket_expr returns None (invalid), the [ is compared literally against the value character, and the pattern iterator is rewound
  • Valid glob patterns like [a] continue to work as character classes

Test plan

  • cond_bracket_literal_match[[ "$x" == "[]" ]] matches when x is []
  • cond_single_bracket_literal[[ "$x" == "[" ]] matches when x is [
  • cond_valid_glob_bracket[[ "a" == [a] ]] still works as glob pattern
  • All 1751 bash spec tests pass
  • cargo fmt --check and cargo clippy clean

Closes #837

When [[ "$x" == "[]" ]] is evaluated, the incomplete bracket expression
[] is now treated as literal characters instead of failing to match.
Previously, invalid bracket expressions caused match_bracket_expr to
return None, which was treated as a non-match.

Closes #837
@chaliy chaliy force-pushed the fix/issue-837-glob-brackets branch from 23d602e to b8528f0 Compare March 26, 2026 17:24
@chaliy chaliy merged commit 79a4c34 into main Mar 26, 2026
18 of 23 checks passed
@chaliy chaliy deleted the fix/issue-837-glob-brackets branch March 26, 2026 17:31
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.

bug: [[ "$x" == "[]" ]] fails — glob interpretation of quoted bracket pattern

1 participant