Skip to content

[bug] Brace expansion empty member emits a spurious empty field: set -- {a,} yields argc=2 (GNU: 1) #337

Closed

Description

@caomengxuan666

Found by gnusweep3 lane (GNU-syntax deep-water matrix, cat2 e057/e058; WSL GNU Bash 5.3.0 script-file oracle, worktree 0fe8d0f release build).

Repro:

set -- {a,}
echo "argc=$#"
set -- {,a}
echo "argc=$#"

GNU 5.3.0: argc=1 / argc=1 (the empty alternative produces no positional word; unquoted empty word is dropped).
rubash: argc=2 / argc=2 — a spurious empty word survives into the word list (visible as trailing space in echo {a,} -> a vs GNU a).

GNU C owner: braces.c brace_expand() (braces.c:104) — the empty preamble/postamble/alternative path; the resulting word list drops the empty word before field assignment (subst.c expand_word_list_internal, subst.c:13219).
Artifacts: target/issue-suites/results/gnusweep3/cat2/case/e057.* / e058.; minimal probes target/issue-suites/results/gnusweep3/probes/min/m02-brace-empty.

Activity

  1. added
    bug
    gnu-baseline
    on Sep 30, 2026
  2. added 3 commits that reference this issue on Sep 30, 2026
  3. caomengxuan666 commented on Sep 30, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt20/deepsweep (4bcd2b62): {a,} null word was dropped at brace-result assembly (subst.c:12026-12035); sequence elements exempt ({a..A} keeps 33 args including the backslash element).

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

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions