Skip to content

[parity] case arm with for-loop-var pattern loses glob meaning #675

Closed

Description

@caomengxuan666

Battery casemod guard case 17 diverges from GNU bash (5.3.0 oracle; local 5.3.20 agrees).

Repro (casearm17.sh):

for p in "f*" "b*"; do case foobar in $p) echo HIT:$p;; *) echo MISS:$p;; esac; done

GNU: HIT:f* / MISS:b*. rubash: MISS:f* / MISS:b*.

An unquoted $p holding glob characters must stay glob-active in the pattern position. GNU expands each pattern per arm (execute_cmd.c:3712 expand_word_leave_quoted) and matches via strmatch (execute_cmd.c:3736); quoting (not assignment shape) decides literalness.

Suspect owner: src/executor/compound_exec.rs:2489 expand_case_pattern (+ :2941 quote_aware_case_pattern) — the loop-var value likely arrives pre-quoted/marked from the for-list path (src/executor/command_words.rs:471). Note #662's static classifier correctly rejects $... to the slow path, so the bug is in the slow path's quoting/marking, not the fast path.

Activity

  1. caomengxuan666 commented on Oct 16, 2026

    @caomengxuan666
    MemberAuthor

    Fix up as PR #683 (branch fix/issue675-casearm-loopvar): for-list bind sites now run the storage-side dequote (subst.c:4807). Root cause was upstream of case (glob-dead loop vars generally). casearm 30/30, ifcase 55/55. Gate running.

  2. caomengxuan666 commented on Oct 16, 2026

    @caomengxuan666
    MemberAuthor

    Landed as #683 (squash-merged ebb2bb5). Root cause was upstream of case (for-list bindings skipped dequote; loop-var glob was dead generally). casearm 29/30->30/30, ifcase 55/55; gates identical (niu 49=49).

  3. added a commit that references this issue on Oct 16, 2026
  4. added
    bug
    area:glob
    on Oct 17, 2026
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

    area:globbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions