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
compound-assignment quote state leaks between entries: an apostrophe in one element corrupts the rest, declare d=($h) expands, declare d=(\*) globs a single-quoted string #733
Quote state is not contained to the compound-assignment element it belongs to. Three shapes, all from the same family (taxonomy S2: "引号去除→转义解码→字段拆分的阶段顺序无唯一实现;declare/read/alias/直接赋值四入口各一份").
Verified with minimal repros, LF script files, stdout and stderr captured to separate files, oracle = WSL GNU bash 5.3.0. Owner = rubash (reproduced through the engine binary directly, not only through the host).
1. An apostrophe in a "..." element corrupts the quoting of the rest of the literal
Both directions are wrong: the single-quoted element gets expanded, and the double-quoted one stops expanding. The state flips after the element containing '.
2. declare/local with a single quoted compound body drops the quotes, then expands
h=X
declare d1=('$h');printf'[%s]\n'"${d1[0]}"
result
GNU bash
[$h]
niu / rubash
[X]
3. …and then runs pathname expansion on it — a single-quoted glob is globbed
This is the one I would fix first: a single-quoted'*' must never be a glob, and here it silently becomes a filename from the cwd. Any declare -a x=('...') whose body contains a glob metacharacter silently changes the data.
Environment / method
Niubash 1.4.0 (rubash git e785c3c8f610), Windows 10 x64 (build 19045). Each shell launched directly against the same LF script file; stdout and stderr written to separate files (> out 2> err) because a single 2>&1 capture interleaves differently and produced a false positive earlier.
Activity
Merge pull request #792 from unixwin/fix/733-compound-assign-quote-leak