Repository navigation
fix(set): stop set scan at -- so set -- -t is positional (rubash#3410) - #3759
Conversation
…h#3410) The script-reader scan routed `set -- -t` to the grouped reader as if it set onecmd: `set_args_may_set_onecmd` (and its verbose/history siblings) walked every `-` bundle on the line without ever stopping at `--`, so the `-t` past it was read as an option-bundle member. GNU stops option interpretation at the first `--` (builtins/set.def pre-scan 671-691, apply loop 716-772, flags.c:372-382) — and at a lone `-`, and at the first non-option word its getopt would not consume as a `-o` operand — so `set -- -t` leaves `$1` as `-t` with no option touched, and `set -- -o onecmd` leaves both words as positionals. The fix is one shared walk, `set_option_words`, modelling that scan: `--` / lone `-` / first unconsumed non-option word end the option region, and every `o` in a bundle consumes one following non-dash word as its option name (`set -o -t` still sets onecmd via the `-t`, `set -o onecmd -t` via the `-t` after the operand). The three token scanners (onecmd, verbose, history) and the `-o` long-name checks (`set -o onecmd` / `set -o verbose`, previously a bare line substring that fired past `--` and in comments) all read from it. The executor needed no change: it already assigns `$1` as `-t` and leaves onecmd off in the `-c`, stdin and script drivers (verified on baseline 8100d76), so this defect was routing-only. Side effects of the shared walk, both GNU-faithful: the history scan no longer under-admits a bundle `o` operand (`set -eo history` enables history, `set -o -H` enables histexpand via the `-H` the `-o` refused to consume); `set +o history` now over-admits to the grouped reader, which costs only the incremental driver. Regression pin `tests/issue3410_set_double_dash_scan.rs`: 11/11 pass (fail-first on the unpatched tree: 7 passed / 4 failed — the three `--` routing tests plus the `set -eo history` control). Oracle: GNU bash 5.2.21 script-file probes (a script stops after the `set` unit iff onecmd was really set). ## Verification (all run, per-item counts) - New pin `tests/issue3410_set_double_dash_scan.rs`: **11/11 pass** (6 routing tests: onecmd/verbose/history `--` stops + controls; 5 end-to-end script guards/controls). - `cargo test --lib`: **1249 passed, 0 failed, 4 ignored**. - Neighbours, all green, no new failures: `issue3322` 5/5, `issue2960` 14/14, `issue2773` 8/8, `issue2957` 2/2, `issue2961` 6/6. - `cargo fmt --check` and `git diff --check` clean. - Vendored GNU source is absent in this checkout (`third_party/bash/` is an empty dir), so the set.def/flags.c citations above follow the issue's recorded references, verified behaviourally against the GNU 5.2.21 oracle.
|
Thanks for the PR — and for the thorough write-up. Per the owner's rule, external PRs are reviewed by the captain first; this one is queued for captain review, and I have done a first pass below. No merge and no requested changes from me. What I read (full diff, 2 files, +404/−77) The fix is one shared walk, The new pin file CI, checked by name (not by colour)
Notes for the captain's review (from the PR body, not new findings)
Thanks again — the captain will pick this up for full review and the stem re-run. |
|
【WIN-AGENT-AUDIT】s2 PR #3759 第1轮 — 建议:PASS(已合并 299d11d) 机制核查:
腿:
F 点:无 合并:299d11d545cbef7abcdbcc52d4ab081bb72bf8a0(squash,未删分支) |
Fixes #3410.
The script-reader scan routed
set -- -tto the grouped reader as if it set onecmd:set_args_may_set_onecmd(and its verbose/history siblings) walked every-bundle on the line without ever stopping at--. GNU stops option interpretation at the first--(builtins/set.def pre-scan 671-691, apply loop 716-772, flags.c:372-382) — and at a lone-, and at the first non-option word its getopt would not consume as a-ooperand.The fix is one shared walk,
set_option_words, modelling that scan; the three token scanners (onecmd, verbose, history) and the-olong-name checks all read from it. The executor needed no change: it already assigns$1as-tand leaves onecmd off in the-c, stdin and script drivers (verified on baseline 8100d76), so this defect was routing-only.Regression pin
tests/issue3410_set_double_dash_scan.rs: 11/11 pass (fail-first on the unpatched tree: 7 passed / 4 failed). Oracle: GNU bash 5.2.21 script-file probes.cargo test --lib: 1249 passed, 0 failed, 4 ignored. Neighbours all green: issue3322 5/5, issue2960 14/14, issue2773 8/8, issue2957 2/2, issue2961 6/6.cargo fmt --checkandgit diff --checkclean.Notes: the shared walk also fixes two history-scan under-admissions (
set -eo history,set -o -H);set +o historynow over-admits to the grouped reader (costs only the incremental driver). Vendored GNU source is absent in this checkout (third_party/bash/is an empty dir), so the set.def/flags.c citations follow the issue's recorded references, verified behaviourally against the GNU 5.2.21 oracle.