Skip to content

audit B4: shopt / set -o / POSIX-mode matrix — 9 fixes (UNVERIFIED-BY-CAPTAIN) - #2675

Merged
caomengxuan666 merged 2 commits into
masterfrom
audit/b4-shopt
Nov 3, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
audit/b4-shopt

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

UNVERIFIED-BY-CAPTAIN — deep-audit round 2, lane B4 (shopt / set -o / POSIX-mode behavioral matrix). Captain re-verification required before merge.

Systematic 4-cell differential matrix (GNU off/on × rubash off/on) over every shopt option (59) and every set -o flag (27), plus listing formats, exit codes, SHELLOPTS/BASHOPTS/BASH_COMPAT import, inheritance, and the POSIX-mode delta list — all against the GNU bash 5.3.20 oracle (binary + C sources).

13 findings: 9 fixed here, 4 report-only. Full report with per-finding evidence, GNU file:line citations, the complete option × 4-cell coverage table, and verification tallies lives in the lane workspace (~/workspace/deep-audit/b4/REPORT.md).

Fixed:

  • F01 bash_source_fullpath inert — push_bash_source pushes sh_realpath (variables.c:5719-5736), resolved against the shell's logical PWD.
  • F03 shopt -o set/unset with an invalid name returned 1; GNU keeps 0 outside query/list forms.
  • F06 lithist space-joined multi-line commands after reserved words (bashhist.c).
  • F07 compat44 subshell loop_level reset ungated (execute_cmd.c:1641-1642) + residual break/continue absorbed at the fork boundary.
  • F08 POSIX bad substitution ignored the compat ≤ 43 error class (subst.c:10285-10288).
  • F09 BASH_COMPAT env import rewrote the value (4.3→43) and swallowed the out-of-range diagnostic (shell.c:1974-1986).
  • F10 POSIX mode: prefix assignments before special builtins (v=zz readonly, v=ww export) did not persist — the non-POSIX setattr absorption arm (setattr.def:590-614) no longer runs for POSIX special builtins.
  • F11 POSIX set listing used $'...' quoting; the ansic branch is POSIX-gated in GNU (variables.c:1126-1142).
  • F12 POSIX export -p/readonly -p value-less + assoc forms, kind-aware (-A) attrs builders, assoc values via the assoc formatter.

Report-only (in the report, with mechanisms + discriminating probes):

  • F02 extquote OFF inside double-quoted ${...} — needs the lex-time verdict threaded into stored words (parse.y:4053).
  • F04 set -v echoes rendered commands at execution, not input lines as read (flags.c:284) — driver-architecture change.
  • F05 interactive $-/job-control init — REPL establishment layer.
  • F13 varredir_close OFF ignored: command-scoped {var} fds always closed at command end (redir.c:972 undo gate) — fdwalk structural project.

Verification (lane-local, pre-captain): post-fix probe suite 54/54 vs oracle; regression pins tests/audit_b4_shopt_regressions.rs 9/9; all matrix harnesses re-run (remaining diffs are the report-only findings plus previously catalogued cross-lane/artifacts); adjacent suites green (one proven-environmental failure in issue1043_1054: the python launcher's inherited SIGXFSZ=SIG_IGN, documented in the report).

Deep-audit lane B4 (round 2): systematic 4-cell differential matrix of
every shopt option (59) and set -o flag (27) against GNU bash 5.3.20.

- F01 bash_source_fullpath inert: push_bash_source now pushes
  sh_realpath(name) when the option is set (variables.c:5719-5736
  push_source), resolving against the shell's logical PWD.
- F03 shopt -o set/unset with an invalid name returned 1; GNU keeps 0
  outside the query/list forms (builtins/shopt.def).
- F06 lithist space-joined after reserved words: the lithist branch
  of build_recorded_entry now precedes the NO_SEMI space join
  (bashhist.c: lines are saved with their newlines).
- F07 compat44 subshell loop_level reset ungated: subshell entries
  keep the loop depth as inherited at level <= 44
  (execute_cmd.c:1641-1642), and the flat-region dispatch absorbs a
  residual break/continue at the fork boundary.
- F08 POSIX bad substitution ignored the compat <= 43 error class:
  both FORCE_EOF consumption sites gated on level > 43
  (subst.c:10285-10288 bad_substitution).
- F09 BASH_COMPAT import rewrote the value and swallowed the range
  diagnostic: the import loop consumes pre-mutation snapshots of
  SHELLOPTS/BASHOPTS instead of the rebuilt BASHOPTS, and the
  sv_shcompat error is reported at startup (shell.c:1974-1986;
  builtins/shopt.def:654-708 set_compatibility_level).
- F10 POSIX special-builtin prefix assignments did not persist: the
  setattr absorption arm (builtins/setattr.def:590-614 — the
  non-POSIX mechanism) is skipped for POSIX special builtins
  (variables.c push_posix_temp_var / merge_temporary_env).
- F11 POSIX set listing used $'...' quoting: shell_quote's ansic
  branch is gated on non-POSIX (variables.c:1126-1142
  print_var_value).
- F12 POSIX export/readonly -p value-less and assoc forms: shared
  posix utility-form renderer, kind-aware (-A) attrs builders, and
  assoc values rendered through the assoc formatter.

Report-only: F02 (extquote lex-time gate, parse.y:4053), F04 (set -v
read-time echo, flags.c:284), F05 (interactive job-control init),
F13 (varredir_close undo gate, redir.c:972 — fdwalk project).

Regression pins: tests/audit_b4_shopt_regressions.rs (9 tests).
UNVERIFIED-BY-CAPTAIN.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant