Skip to content

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

@chaliy

Description

@chaliy

Problem

[[ "$x" == "[]" ]] fails to match when x="[]". The [] on the right side of == inside [[ ]] is incorrectly interpreted as a glob pattern instead of a literal string.

Reproduction

x="[]"
if [[ "$x" == "[]" ]]; then echo "match"; else echo "no match"; fi

Real bash: match
Bashkit: no match

Root cause

In [[ ]], the right side of == supports pattern matching. However, [] is an incomplete/invalid glob character class and real bash treats it as a literal string. Bashkit's pattern matcher is likely consuming the [] as a glob construct.

Related patterns that may also be affected:

[[ "$x" == "[" ]]     # literal bracket
[[ "$x" == "]" ]]     # literal bracket
[[ "$x" == "[a]" ]]   # this IS a valid glob — should match "a"

Impact

Breaks any script that compares against bracket-containing strings. The wedow/ticket script compares deps: [] YAML values against literal "[]" — this bug causes all dependency operations to malfunction (deps always appear non-empty).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions