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
a scalar whose text looks like a parenthesised list is re-parsed as an array by "${x[@]}" (element count and $# change) #755
A scalar whose value happens to look like a parenthesized list is re-parsed as an array when expanded with [@]. The element count changes, so "${x[@]}" — the standard idiom for "this may be a scalar or an array" — silently yields the wrong number of words.
This is not a prompt/REPL bug. It is expansion, and it looks like the same root as the S5 family the taxonomy names ("文本切片+再解析替代 parse_and_execute 一体化"): the value's text goes back through a parser.
Repro
x='(a b c)'printf'[%s] len=%s\n'"${x[@]}""${#x[@]}"set -- "${x[@]}";echo"argc=$#"
y='plain'printf'control:[%s] len=%s\n'"${y[@]}""${#y[@]}"
"${x[@]}"
${#x[@]}
set -- "${x[@]}" → $#
GNU bash
one element (a b c)
1
1
niu / rubash
three elements: a, b, c
3
3
control y='plain'
one element
1
1 (both shells)
The control matches, so it triggers specifically when the scalar's text contains the parentheses.
Why this is high severity
"${x[@]}" is the documented way to accept "a variable that may be a scalar or an array". Downstream $#, for counts, "$@" forwarding and positional indexing all shift.
The trigger is ordinary data: an ls-style glob stored in a variable, a regex, a shell snippet in a config value, a log line, a find expression.
The failure is silent — no diagnostic, just a different word count.
It is not limited to the prompt path: the README of the failing case above is a plain expansion in a plain script.
Method
LF script file; niu (installed 1.4.0) and WSL GNU bash 5.3.0; stdout and stderr captured to separate files. No PTY involved.
Activity
fix(executor): type the array-vs-scalar verdict and report malformed …
fix(executor): type the array-vs-scalar verdict and report malformed …
fix(executor): treat prefixed array storage as an array, completing #755
fix(executor): treat prefixed array storage as an array, completing #755