Skip to content

[bug] posix round-trip stickiness: 'set -o posix' enables inherit_errexit but 'set +o posix' never resets it (GNU 5.3 keeps it sticky; rubash never flips it at all) #383

Closed

Description

@caomengxuan666

Side-find by the wt30/perf1x lane (2026-10-01) while auditing comsub errexit entries; pre-existing, out of that lane's scope.

Shape (WSL GNU Bash 5.3.0 verified)

set -o posix enables inherit_errexit, and a later set +o posix does NOT reset it — the flag is sticky across the posix round-trip. rubash never flips inherit_errexit at all, so after a posix round-trip the comsub-errexit behavior diverges (the lane's matrix m1y.sh cases 22/24/25).

Reproducer set is preserved at the perf1x lane artifacts (target/perf1x/m1y.sh in the wt30 worktree — regenerate if the tree was cleaned: set -o posix; set +o posix; sh -c 'exit 3'; v=$(false); echo $? shapes vs GNU).

GNU spec pointer

options.c/bashopt table + flags.c: posix mode toggling applies/clears derived options on entry but the reverse trip does not undo them (GNU 5.3 behavior measured; find the owning table walk in options.c posix_changed / set_posix_mode before fixing — cite exact lines).

Notes

  • Options-family work should build on the just-landed single-source option table (74a06435 removed the errexit/xtrace live markers); inherit_errexit now has exactly one home.
  • Pairs naturally with rubash#382 (exit-code fidelity) in one options/exit-status lane.

Activity

  1. added 2 commits that reference this issue on Oct 2, 2026
  2. caomengxuan666 commented on Oct 2, 2026

    @caomengxuan666
    MemberAuthor

    Landed as d684a7a (wt32/optfix lane faa702f2): the builtins/set.def:403-418 set_posix_mode walk is ported — enable turns on interactive_comments/sourcepath/expand_aliases/inherit_errexit/shift_verbose; disable resets only expand_aliases (interactive default) + shift_verbose, inherit_errexit stays sticky exactly like GNU (general.c:103-128 posix_initialize over the posix_vars table). set_shell_option is the single funnel (fast path/slow path/shopt -o/local - bitmap/CLI startup); function_locals - bitmap snapshots the posix_vars tail. Two-shell matrix probe383a-h byte-identical incl. the m1y comsub-errexit family; tests/issue383_* 9/9. Residual noted: POSIXLY_CORRECT-from-env startup does not run the walk yet (startup env handling, separate).

  3. added
    bug
    area:cmdline
    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:cmdlinebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions