Skip to content

ANSI-C $'...' array element with decoded quote stores untagged bare quote (quote removal strips it) #109

Closed

Description

@caomengxuan666

Repro (vs GNU bash 5.3.0(1), WSL /usr/local/bin/bash oracle)

x=($'a"b'); printf '%s' "${x[0]}" | od -An -tx1
# GNU 5.3.0: 61 22 62   (a"b)
# rubash:    61 62      (ab)

Analysis

The compound-assignment storage split receives the ANSI-C-decoded element as
a"b — a bare " with no E010/E011 tagging (the
escape_decoded_ansi_c_quotes marker contract is not applied on this path).
append_array_value then runs quote removal over the partially-quoted token
and treats the bare " as an operator pair, stripping the decoded data quote.

Discovered while fixing the niubash #103 array side-findings
(rubash PR #108, commit 742a544). The ordering fix there
(raw-token quote removal -> carrier restore -> unquote) fixed the
backslash-escape cases (x=(q\"q), x=("q\"q")) and the
sh_double_quote render cases, but this variant needs the upstream
ANSI-C decoder to tag decoded quotes so quote removal can tell data
from syntax — a different layer.

Pre-existing on master 9729b14; not a regression of #108.

Activity

  1. added
    bug
    on Sep 16, 2026
  2. caomengxuan666 commented on Sep 18, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by cb0c0ed (merged 3017d93). Root causes: UTF-8 latin-1 promotion in rewrite_compound_element_subscripts; missing U+E010/E011 carrier restore at the storage boundary (quote_array_value); wrong fully-quoted detection for mixed-quote tokens; empty $'' dropped; $' decoded inside "..." in compounds. 28/28 probes byte-identical to GNU 5.3.0 including the original 61 22 62 repro. Residuals documented in commit message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions