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
Error when ternary operator is used in substring expansion (offset or length) #317
This is an awkward one to parse, yet unfortunately a common idiom. An example seen in the wild, and two minimal reproducible examples:
# seen in the wild; parses with MISSING '}' after first '}'
address=${address: ${#address} < 8 ? 0 : -8} # Limit to 32-bit
# minimal example 1: parses with ERROR; bash evaluates as ${FOO:0:2}
echo ${FOO: 0 : 1 ? 2 : 3}
# minimal example 2: parses with ERROR; bash evaluates as ${FOO:2:4}
echo ${FOO: 1 ? 2 : 3 : 4}
All parse correctly with parentheses around the ternary expression.
Full parse trees
Parse trees for each example (without comments) from the playground, but found using tree-sitter-bash 0.25.1.
Activity