Skip to content

executor: expanded '#' command words are commands, not comments - #3271

Merged
caomengxuan666 merged 9 commits into
masterfrom
fix/P4A-3020-2683
Nov 10, 2026
Merged

caomengxuan666 merged 9 commits into
masterfrom
fix/P4A-3020-2683

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #3020
Refs #2683

What changes

execute_assignment_or_comment_command in src/executor/command_prepare.rs carried an arm that discarded any simple command whose first expanded word starts with #, reporting exit code 0. GNU bash treats comments as purely lexical (parse.y:3630-3643): the reader discards a # only when it begins a word in the source text where a word can start. Quoted, expansion-produced, command-substitution-produced and variable-carried #... words are command names and report command-not-found (127). Source-text comments never reach the executor as words because the scanner consumes them, so the arm had no legitimate input and is removed (4 lines).

Note on the second issue

The same-line shopt/extglob pins were re-measured on the current master base e1afd25d before any edit: all 10 pass. The earlier 2 red cells were healed by the read-unit entry snapshot work that landed for the neighbouring read-unit issue (PR #3223, commit f7fed212): its deferred extglob parking, the grouped feeder entry snapshot and the parse-loop marker arming cover the same grouped-driver mechanism. This PR therefore carries no product change for that side; the re-measurement is recorded here and in the lane report as evidence for the captain's decision.

Verification (base e1afd25d, per-stem result lines)

  • Pin stem for the hash-word issue: 3 passed / 6 failed before, 9 passed / 0 failed after.
  • Pin stem for the same-line shopt issue: 10 passed / 0 failed (already green on base, see note).
  • Neighbour stems all green: read-unit extglob snapshot 11/11, eval extglob gate 13/13, stdin conditional group 9/9, fndef inline comment 4/4, shopt audit 1/1.
  • Lib: 1207 passed / 0 failed / 4 ignored; the recorded base failure name set is empty, so no new failures.
  • RUSTFLAGS="-D warnings" check: clean at lib scope. The wider all-targets check is red on base and head alike from pre-existing warnings in unrelated test files (the export-function-render stem and the this-sh declare-listing stem); untouched by this change and left for their owners.
  • cargo fmt --check: clean. Marker-literal lint: OK.

本 PR 删除了什么

Removed the 4-line executor arm described above (one if block in src/executor/command_prepare.rs). Nothing else is deleted; no test files change (the pins are already on master via PR #3163).

A word whose expanded text starts with '#' was silently discarded with exit code 0 by execute_assignment_or_comment_command. GNU bash treats comments as purely lexical (parse.y:3630-3643): only a '#' that begins a word in the source text, at a position where a word can start, is discarded by the reader. A quoted or expansion-produced '#...' word is a command name and reports command-not-found (127).

Source-text comments never reach the executor as words (the scanner consumes them), so the arm has no legitimate input; remove it.

Verification on base e1afd25: pin stem issue3020 goes 3/9 -> 9/9; lib 1207 passed / 0 failed / 4 ignored; -D warnings clean at lib scope; fmt clean.

Refs #3020
Refs #2683
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 10, 2026 16:30
@caomengxuan666
caomengxuan666 merged commit 10a0d45 into master Nov 10, 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