You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pattern: unmatched opening bracket should be treated as a literal #1372
go mod init example.com/mvdan-reprogo get mvdan.cc/sh/v3@v3.13.1go run .
Actual output:
regexp="" error=*pattern.SyntaxError [ was not matched with a closing ]
The corresponding Bash pattern matches the literal opening bracket:
case"["in
[) echo match ;;
*) echo miss ;;
esac
Bash output:
match
Would it be appropriate for shell-pattern compilation to treat an unmatched [ as a literal, while retaining errors for malformed constructs that Bash also rejects?
Implemented as PR #1377 — an unmatched [ is now emitted as a literal and the rest of the pattern is reparsed, matching Bash. This also fixes case-statement matching in the interp: case "[" in [) now matches as it does in Bash.
Activity
Pastalikek65 commentedon Aug 10, 2026
Implemented as PR #1377 — an unmatched
[is now emitted as a literal and the rest of the pattern is reparsed, matching Bash. This also fixescase-statement matching in the interp:case "[" in [)now matches as it does in Bash.pattern,interp: add test cases for unmatched bracket patterns
pattern: treat an unmatched [ as a literal, like Bash