Skip to content

driver: read-time set -v echo; job-control diagnostics print shell_pgrp (W-I2) - #3239

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix/W-I2-driver-monitor
Nov 11, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix/W-I2-driver-monitor

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Wave-2 pin-to-fix lane W-I2 (driver / interactive face). The two pin files are carried verbatim from pin PR #3172 (branch test/wave2-pins-i2, head 64209f64) as the first commit of this branch; that pin PR itself is left for the captain to dispose of.

Refs #2773
Refs #2774

Mechanism

Verbose echo (set -v): GNU echoes each input line to stderr as it is READ, under the flag state then in effect (flags.c:284 echo_input_at_read = verbose_flag; parse.y:2712 prints shell_input_line; heredoc secondary lines echo via make_cmd.c:584 read_secondary_line). The engine echoed the rendered command at execution time from Executor::set_current_command, which split ;-joined lines per command, dropped comments, re-rendered compound bodies per stage and per iteration, and never echoed comment, blank, or continuation lines.

  • New single echo point script_driver::echo_verbose_input_lines, called at every real read point: the grouped reader's per-line consumption (read_next_source_group), the stdin script reader's per-line read (run_stdin_script), and the whole-string read boundaries (the -c and Session fast paths, and parse_and_execute strings via execute_eval_source).
  • New over-admitting routing scan script_driver::script_may_toggle_verbose (same family shape as script_may_set_onecmd): a text that may toggle verbose mid-read takes the grouped reader on the script-file, -c, and Session routes; a script file entered with verbose already on takes it too. The fast paths keep a single boundary echo, which is the same answer when the scan shows the entry state holds for every line. The scan only routes; it decides no semantics.
  • The execution-time echo arm in set_current_command is deleted (see the deletion section below).

Job-control diagnostics: GNU prints shell_pgrp — jobs.c:4737 shell_pgrp = getpgid (0) at initialize_job_control entry, reported by jobs.c:4844/4853. Both establishment print sites printed the shell's pid instead; they now share script_driver::shell_process_group_id(). The monitor-mode establishment itself was already correct (the second pin is a regression lock, green before and after).

GNU anchors

  • flags.c:284; parse.y:2712; make_cmd.c:584
  • jobs.c:4731-4869 (4737, 4844, 4853, 4858, 4869); shell.c:1969
  • All behavioral claims probed against GNU bash 5.3.20 (vendored oracle): -c strings read line by line like files (mid-string toggles start/stop the echo), heredoc body and delimiter lines echo, sourced-file lines echo with the toggle persisting after return, stdin scripts echo per line read, and the job-control diagnostic names the inherited process group when pid != pgid.

Verification (Simular box, this branch head 1eecaa94 on e1afd25d)

Local build environment was under a write wall (probe battery FAIL), so all build legs ran on the Simular box; the numbers below are per-stem test result lines from those logs.

  • Fail-first on base beab07dc: verbose stem 1 passed / 7 failed (only the toggle cell green, by coincidence of rendering); job-control stem 4 passed / 0 failed (regression lock — matches the pin lane's own record on the older base).
  • Head: verbose stem 8 passed / 0 failed; job-control stem 4 passed / 0 failed.
  • Neighbor stems all green: case_command_head_bash_command_regressions 4, issue1040_ps4_xtrace_regressions 2, heredoc_regressions 3, issue1563_eval_source_errexit_frame_regressions 13, issue1102_exec_stdin_regressions 1, issue1573_stdin_conditional_group_regressions 4, issue1476_lastpipe_monitor_regressions 1, issue1494_jobs_refresh_regressions 2, issue1016_1072_1073_1254_1255_history_interactive_regressions 7, issue1252_interactive_defaults_regressions 3.
  • Lib tests bilateral: head 1207 passed / 0 failed; base 1207 passed / 0 failed; failure-name sets empty on both sides.
  • RUSTFLAGS="-D warnings" on product code (--lib --bins): rc=0. The --all-targets form is red only on a pre-existing unused variable in tests/issue2078_session_parse_cache_regressions.rs:129, byte-identical failure on the base commit; this branch does not touch that file.
  • cargo fmt --check full tree: rc=0.
  • Binary probes on the head build: the no-tty interactive diagnostic prints the process-group number (probe: group 185143, child pid different); heredoc, source, stdin, and eval verbose shapes byte-match the GNU recordings.

Collision notes for sequencing

Open PRs touching files in this branch, all with hunks distant from these changes: #2968 (public_accessors, trap_exec), #3135 (public_accessors), #3234 (trap_exec), #3238 (trap_exec). No open PR touches src/script_driver.rs, src/main.rs, or src/api/session.rs. Master has advanced past this branch's base since the rebase (e1afd25d); an update-branch may be needed before merge.

本 PR 删除了什么

  • The execution-time verbose echo arm in Executor::set_current_command (src/executor/public_accessors.rs): the if shell_option_enabled(..., "verbose") block that wrote the rendered bash_command_source_text(cmd) to stderr, together with its comment block (14 lines). The $BASH_COMMAND bookkeeping that shares the preamble is kept; only the echo is gone, replaced by a comment pointing at the read points.
  • Nothing else is deleted. The two job-control print sites keep their lines; only the printed value expression changes from the pid to the shared process-group helper.

…rol (from PR #3172)

Pins taken verbatim from PR #3172 head 64209f6 (tests only):
- tests/issue2773_set_v_read_time_echo.rs (8 cells)
- tests/issue2774_interactive_no_tty_job_control.rs (4 cells)

Refs #2773
Refs #2774
…ntrol diagnostics

set -v (verbose): GNU echoes each input line to stderr as it is
READ, under the flag state then in effect (flags.c:284
echo_input_at_read = verbose_flag; parse.y:2712 prints
shell_input_line; heredoc secondary lines via make_cmd.c:584).
The engine instead echoed the RENDERED command at execution time
from Executor::set_current_command: a `;`-joined line echoed once
per command with comments dropped, a multiline compound echoed
per stage and per iteration, comment/blank/continuation lines
never echoed, and -c strings sampled wrong.

- script_driver::echo_verbose_input_lines is the single echo
  point, called at every real read point: the grouped reader's
  per-line consumption (read_next_source_group), the stdin script
  reader's per-line read (run_stdin_script), and the whole-string
  read boundaries (the -c and Session fast paths, reached only
  when the toggle scan below shows the entry state holds for
  every line, and parse_and_execute strings via
  execute_eval_source).
- script_driver::script_may_toggle_verbose is an over-admitting
  routing scan in the script_may_set_onecmd family shape: texts
  that may toggle verbose mid-read (set -v/+v, a bundled -/+...v,
  set -o/+o verbose, or a ./source/eval unit whose body can) take
  the grouped reader on the script-file, -c and Session routes;
  a script file entered with verbose already on takes it too.
  A false positive only costs the incremental driver.
- The execution-time echo arm in set_current_command is deleted;
  the preamble keeps only its $BASH_COMMAND bookkeeping.
- Job-control diagnostics: GNU prints shell_pgrp (jobs.c:4737
  getpgid (0) at initialize_job_control entry; diagnostics at
  jobs.c:4844/4853). Both establishment print sites (the
  script_driver funnel and main.rs's non-interactive -m arm)
  printed the shell's pid instead; they now share
  script_driver::shell_process_group_id.

Refs #2773
Refs #2774
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 11, 2026 03:51
@caomengxuan666
caomengxuan666 merged commit 401407e into master Nov 11, 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