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] terminator-less 'then' after ]] inside a function body rejected — GNU accepts (breaks shell_function_n_shortcuts/.shortcut) #460
tc.sh: line 2: syntax error near unexpected token `then'
GNU bash 5.3.0 accepts this file. bash -n at top level WITHOUT the function wrapper (if [[ $x == y ]] then ... fi) is accepted by rubash, and the ;-terminated form (if true; then) inside a function is accepted — only the terminator-less then directly after ]] inside a function body is rejected. The same construct in a while/until condition or at top level parses; a plain if cmd then (non-conditional) is rejected the same way as GNU.
Asset is an interactive prompt function; parsed clean by GNU.
GNU C source anchor (vendored bash.git @b4608166, Bash-5.3 patch 15)
parse.y:1178 if_command: IF compound_list THEN compound_list FI — the condition is a compound_list.
parse.y:1262 compound_list: newline_list list0 | newline_list list1 — the list1 alternative requires no list terminator.
parse.y:1323-1324 list1: ... | pipeline_command — a single pipeline_command is a complete list1, so [[ ]] followed directly by THEN is grammatical.
parse.y:5899 reserved_word_acceptable() — COND_END is in the acceptable-predecessor set, so then IS recognized as the reserved word THEN when it follows ]].
Shrunken 5-line repro (from the 2876-line asset, dual-condition rubash-fails/GNU-grammar-accepts):
PRPT() {
if [[ $charge=="Discharging" ]] thenecho"$e_line1"fi
}
Classification
Parser divergence (conditional command inside function body, terminator-less THEN). Not covered by rubash#435 (multi-line (( )), fixed in fa87622) — that fix restored the top-level/multi-line arithmetic form; this is the if/elif + [[ ]] + then list-terminator form inside function bodies.
Activity
docs(audit): wt98b/goldtri ecosystem gold triage — 172 rows classifie…
merge wt98b/goldtri: 172-row gold triage — 27 already-fixed (fa87622/…
chore(release): prepare 1.4.0 (version bump, CHANGELOG, packaging sli…
parser: reserved words after (( ))/[[ ]] compounds (Refs #2646)