Skip to content

[regression] posix mode expands reserved-word aliases (-o posix + alias for=echo) — alias suite 0->2, introduced by 815802eb #414

Closed

Description

@caomengxuan666

Summary

Full-rebaseline round wt42 (2026-10-02, master dc3e799): the true-baseline
alias suite moved 0 -> 2 diff lines vs the 2026-09-25 documented ledger
(82 zero / 1 residual). rubash now applies a reserved-word alias (alias for=echo)
in posix mode, where GNU bash 5.3.0 keeps the loop keyword. Introduced by
today's 815802eb (fix(#390) parse-error wording/rc parity) — git-bisect
verified: 2680e79 good, 815802e first bad.

Reproducer (script file, newline form)

posix-alias-inner.sh:

alias al=" "
alias foo=bar
alias for=echo
al for foo in v
do echo foo=$foo bar=$bar
done

WSL GNU Bash 5.3.0 bash -o posix posix-alias-inner.sh:

foo=v bar=

rc 0 — in posix mode the for word is NOT replaced by the echo alias;
the real for-loop runs.

rubash (dc3e799, worktree build) rubash -o posix ...:

foo in v
posix-alias-inner.sh: line 5: syntax error near unexpected token `do'

rc 2 — the reserved-word alias was expanded (default-mode behavior).

Default mode (shopt -s expand_aliases first) is byte-identical in both
shells (foo in v, rc 2, same error wording) — only the posix leg diverges.
Both shells also agree that alias for=echo DEFINES the alias in posix mode
(alias -p shows it) — the divergence is at expansion time, not definition.

Suite impact

alias.tests last block (${THIS_SH} -o posix -c '...' bash): GNU prints
foo=v bar= + no error; rubash prints foo in v + syntax error near unexpected token do at line 6 instead of GNU's line-7 default-leg error —
2 stdout diff lines (ledger line alias 2 env=0).

GNU anchors (from third_party/bash)

  • parse.y:5755 unconditional CHECK_FOR_RESERVED_WORD(token) in
    read_token_word() before the alias block — a reserved word at a
    reserved-acceptable position returns as the keyword token.
  • parse.y:5757-5765 alias expansion (expand_aliases && quoted == 0 ->
    alias_expand_token, parse.y:3249).
  • parse.y:5767-5768 if (posixly_correct == 0) CHECK_FOR_RESERVED_WORD(token)
    — the post-alias reserved-word recheck is default-mode only (this is the
    "default mode allows reserved words to be aliased, posix says no" lever
    the upstream alias7.sub comment names).
  • The exact interplay with PST_ALEXPNEXT (parse.y:3254 eligibility,
    parse.y:2098 set-on-pop_string) needs the fixer's read; empirically the
    contract is: posix keeps the loop keyword, default replaces it.

Bisect evidence

  • good 2680e79 (2026-10-01 tip) — alias suite 0, probe prints foo=v bar=
  • bad dc3e799 — alias suite 2
  • first bad: 815802e (src/parser/token_actions.rs reserved-word abort
    predicate + parse_loop.rs push_unexpected_token_error) — the same commit
    that (correctly, GNU-verified) tightened the ;-one-buffer reserved-word
    rejection; its predicate rearrangement appears to have dropped the posix
    gate from the deferred-alias path.

Artifacts

  • target/issue-suites/results/wt42-verify/posix-alias-{inner,def,run2}.sh,
    pa-gnu.{out,err} (GNU ground truth), pad.sh (definition probe)
  • target/issue-suites/results/true-baseline/alias/{gnu.out,rb.out,gnu.err,rb.err}
  • Ledger: target/issue-suites/results/true-baseline-ledger.log (final run, 2026-10-02)

Found by wt42/rebaseline full-regression lane (cargo-test side of the same
commit was 9 stale alias tests, fixed separately in 80479503 — this is the
engine-side residue the suite caught).

Activity

  1. added a commit that references this issue on Oct 2, 2026
  2. caomengxuan666 commented on Oct 2, 2026

    @caomengxuan666
    MemberAuthor

    Landed as d5c30a0c (wt43/hotfix): two invariant fixes, no rollback of #390 — (1) the driver fast-path admission now disqualifies for live alias expansion at startup (CLI -o posix/--posix/-O expand_aliases), since a script-file's inline 'alias' definitions must be able to affect parsing (GNU shell.c:1853 init_noninteractive: expand_aliases = posixly_correct); the subprocess path keeps the textual check because 'set -o posix' unbinds POSIXLY_CORRECT (set.def:415-416) and is not inherited. (2) lexer::expand_aliases_in_source only modeled the DEFAULT-mode ordering; posix's PRE-check (parse.y:5751-5755 read_token_word CHECK_FOR_RESERVED_WORD before the alias block 5757-5765, default post-check 5767-5769) is now a shared check_reserved_word with a !posix gate, the posix flag threaded through expand_group_aliases/comsub splices. 48-shape matrix (12 forms x posix/default x script/-c) 44 byte-identical, 4 residuals pre-existing (no-alias for-command diagnostics, verified identical pre-change binary); alias suite 2 -> 0; run-alias upstream suite fixed (the CI red/green diff confirmed it); issue414 suite 9/9; A/B suites byte-identical. CI green (the initial red was the separate cat-streaming issue, fixed in dca2e42).

  3. added 3 commits that reference this issue on Oct 3, 2026
  4. added
    bug
    regression
    area:parser
    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:parserbugregression

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions