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
[parse] =~ regex word with unquoted | + reserved word (case/if) rejected in while/until condition — #322 residue (breaks shellapi odsel) #461
GNU bash 5.3.0 accepts this file (the entire x|case after =~ is a single regex word).
Divergence boundaries measured on the fresh build:
construct
rubash -n
GNU 5.3
[[ x =~ x|case ]] (top level)
ok
ok
if [[ x =~ x|case ]]; then
ok
ok
[[ x =~ ^(a|b)$ ]] (rubash#322 form)
ok
ok
while [[ x =~ x|zebra ]]; do
ok
ok
while [[ x =~ x|case ]]; do
syntax error
ok
until [[ x =~ x|if ]]; do
syntax error
ok
while [[ x =~ (a|case) ]]; do
syntax error
ok
Only the while/untilcondition context fails, and only when the segment after the unquoted | is a compound-command reserved word (case, if) — rubash then lexes case as the reserved word, opens a case command that never closes, and the error surfaces as "unexpected end of file from case' command" (or "unexpected token do'" in the minimal form).
Real-world evidence (ecosystem harvest)
irrequietus/shellapi/modules/odsel/odsel.shellapi.bash, line 59 (harvest 2026-10-04):
while [[ $y=~ ^[[:space:]]*(\||case)[[:space:]]+(.*) ]];do
WSL GNU Bash 5.3.0 bash -n: rc=0 on the whole file (recorded oracle, harvest 2026-10-04/05)
rubash master a157656rubash -n: rc=2, syntax error: unexpected end of file from 'case' command on line 59
Note: rubash's own runtime sources this file (ConPTY run reaches the prompt) — the strict -n parse is what breaks.
GNU C source anchor (vendored bash.git @b4608166, Bash-5.3 patch 15)
parse.y:5167-5170 — after the =~ operator token, the cond parser sets parser_state |= PST_REGEXP.
parse.y:5439-5461 read_token_word() — under PST_REGEXP, ( and | are special-cased inside the regex word: | goes to got_character (folded into the word), ( is consumed via parse_matched_pair (cd, '(', ')', ...); comment: "When parsing a regexp as a single word inside a conditional command, we need to special-case characters special to both the shell and regular expressions. Right now, that is only '(' and '|'."
parse.y:3663 read_token() — if (parser_state & PST_REGEXP) goto tokword; — the whole regex stays one WORD; reserved-word recognition never happens inside it.
This is a residue of the closed rubash#322 fix (2026-09-29): the ^(a|b)$ parenthesized form was fixed, but the pipe-then-reserved-word form inside while/until conditions still splits.
Activity
docs(audit): wt98b/goldtri ecosystem gold triage — 172 rows classifie…
fix(cond): decode raw-byte pairs at the [[ =~ ]] regex boundary (Refs #…