Skip to content

deep-audit B6: diagnostic fidelity fixes (EOF form, times, caller, wait -n) - #2674

Merged
caomengxuan666 merged 3 commits into
masterfrom
audit/b6-diagnostics
Nov 3, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
audit/b6-diagnostics

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Deep-audit Round 2, Lane B6 (rubash diagnostic fidelity & exit-status fidelity). DRAFT — UNVERIFIED-BY-CAPTAIN.

Full lane report: ~/workspace/deep-audit/b6/REPORT.md — 22 findings: 4 fixed here, 18 report-only (byte-verified against GNU bash 5.3.20 throughout; error-class coverage matrix + NEEDS-OWNER-DECISION items in the report).

Fixed in this PR (one commit, per-finding sections in the commit message):

  • B6-F1 — dangling &&/|| at end of input: wrong "near unexpected end of file" form for single commands, and multi-command lists were silently executed. The and-or fold now uses the shared __RUBASH_PARSE_ERROR_EOF__ marker (as the pipeline fold already did) and discards the list; Session API gained the matching diagnostic arm.
  • B6-F2 — times hardcoded a rubash: diagnostic prefix with no line N: segment; the shell diagnostic prefix is now threaded through from the executor (builtins/common.c builtin_error).
  • B6-F3 — caller argument model rewritten in caller.def's order: CHECK_HELPOPT → array-emptiness silence at -c/-s top level → no_options scan (getopt naming, lone -, post--- operands) → GNU valid_number grammar with sh_invalidnum's octal/hex variants. (A caller.def:108 FUNCNAME gate was tried and reverted with evidence: GNU's gate tests the raw array, which carries an invisible main in script mode — pinned by a regression test.)
  • B6-F4 — wait -n on a non-job pid now reports sh_badpid (`N': not a pid or valid job spec, wait.def set_waitlist) instead of wait_for_single_pid's "not a child" text; plain wait unchanged.

Verification (build slot, scrubbed cargo harness): new stem deep_audit_b6_diagnostics 8/8; guards issue519 (5), issue1118 (1), issue1156 (2), issue1064 parse-diag (8), issue1138 (1) all green; cargo check --all-targets and cargo fmt --check clean. 42-shape differential matrix for the fixed classes matches GNU except the two documented non-faces (B6-R17 multi-line EOF line; times CPU-time values stub).

Refs #2620

…mes prefix, caller argument model, wait -n message)

Four root-cause classes from the Round-2 Lane B6 differential sweep
against GNU bash 5.3.20 (full report: deep-audit B6, 22 findings,
4 fixed here, 18 report-only). UNVERIFIED-BY-CAPTAIN.

B6-F1: a dangling &&/|| at end of input got "syntax error near
unexpected end of file" at the command's line (single command) or was
silently EXECUTED (multi-command list). The and-or fold now stores the
shared __RUBASH_PARSE_ERROR_EOF__ marker the pipeline fold already
used (parse.y yyerror EOF form), discards the rest of the list, and
the Session API gained the matching plain-EOF diagnostic arm.

B6-F2: `times` hardcoded "rubash: " with no line segment; it was the
one builtin whose diagnostic never received the shell diagnostic
prefix (builtins/common.c builtin_error). Thread
Executor::diagnostic_prefix() through execute_times ->
times::execute_with_io, mirroring wait's plumbing.

B6-F3: `caller` validated its argument before GNU's availability
checks and with a Rust number grammar. Rewritten in caller.def's
order: CHECK_HELPOPT (common.h:29) -> BASH_LINENO/BASH_SOURCE
emptiness (silent 1; both arrays are empty at -c/-s top level) ->
no_options scan (common.c:157; getopt names "-" + second char; a
lone "-" and post-"--" words are operands) -> GNU valid_number
grammar with sh_invalidnum's octal/hex variants (common.c:214).
No FUNCNAME gate: caller.def:108 tests the raw array, which
open_shell_script (shell.c:1636) keeps non-empty via an invisible
"main" in script mode, so script-file top level validates.

B6-F4: `wait -n` reported a non-job pid with wait_for_single_pid's
"pid N is not a child of this shell" (jobs.c:2754). Under -n, GNU
validates operands against the job table in set_waitlist
(wait.def:352) and reports sh_badpid "`N': not a pid or valid job
spec" (common.c:234). The -n flag is now threaded into both wait
error sites; plain wait keeps the jobs.c text.

Regression tests: tests/deep_audit_b6_diagnostics.rs (8 tests, one
per fixed face family) + a times unit test. Verified via the build
slot with scrubbed_cargo: B6 stem 8/8; guards issue519 (5),
issue1118 (1), issue1156 (2), issue1064 parse-diag (8), issue1138
(1) all green; cargo check --all-targets clean; cargo fmt clean.
@caomengxuan666
caomengxuan666 merged commit 55fb817 into master Nov 3, 2026
11 checks passed
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