Skip to content

testsuite batch90: unquoted ${a[@]OP} drops elements the operator makes empty - #298

Merged
brianjfox merged 1 commit into
mainfrom
fix/testsuite-batch90
Jul 25, 2026
Merged

testsuite batch90: unquoted ${a[@]OP} drops elements the operator makes empty#298
brianjfox merged 1 commit into
mainfrom
fix/testsuite-batch90

Conversation

@brianjfox

Copy link
Copy Markdown
Owner

Summary

An unquoted ${a[@]OP} expansion (per-element operator: ##/%%/pattern substitution/etc.) that reduces an element to empty must drop that element — it splits away — like a plain unquoted ${a[@]} empty element (batch49). gnash instead emitted a spurious empty field.

Fix

Restructured the per-element OP path in expand.cpp to mirror the proven plain-array path:

  • quoted "@": keep empty elements (QNULL)
  • unquoted *: join with first IFS char (splittable)
  • unquoted @: skip empty elements

Scoreboard

  • array 221 → 209 (−12)
  • assoc 94 → 88 (−6)
  • exp 46 → 44 (−2 bonus)

Verification

  • ctest 22/22
  • run_diff: all 234 scripts match bash
  • Broad rescan (nameref/varenv/posixexp/quotearray/more-exp/quote/builtins/glob/dstack/attr): no regressions

Closes #297

An unquoted ${a[@]} whose per-element operator (##/%%/pattern
substitution/etc.) reduces an element to the empty string must produce
no word for that element -- it splits away -- just as a plain unquoted
${a[@]} empty element does. gnash's per-element OP path instead emitted
an unconditional FIELD_SEP boundary, inserting a spurious empty field
(a double space in the joined output).

Restructure the OP path to mirror the proven plain-array path: the
quoted "@" case keeps empty elements (QNULL), unquoted "*" joins with
the first IFS char (splittable), and unquoted "@" skips empty elements.

array.tests line 204 `${xpath[@]%%[!/]*}` and the assoc/exp analogues
now match bash.

Closes #297
@brianjfox
brianjfox merged commit 8762ec7 into main Jul 25, 2026
1 check passed
@brianjfox
brianjfox deleted the fix/testsuite-batch90 branch July 25, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

testsuite batch90: unquoted ${a[@]OP} drops elements the operator makes empty

1 participant