Skip to content

fix(builtins,prompt): #759 builtin divergences (shift usage status, zsh-name builtins, sudo visibility) and #757 prompt expansion (bare specials, promptvars gate) - #810

Merged
caomengxuan666 merged 4 commits into
masterfrom
fix/759-757
Oct 18, 2026

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes #759 (items 2-4; item 1 unset+function already gone on master, item 2 dirs -l fixed in 5da6421)
Closes #757 (facets 1-2; section 3 items stay open)

What changed

#759 item 3 - shift bad-operand status

GNU builtins/shift.def routes a non-numeric operand through get_numeric_arg (builtins/common.c:501-505, sh_neednumarg + return 0 -> return (EX_USAGE) = 2) and a surplus operand through no_args (set_exit_status(EX_BADUSAGE) = 2); only the shift-count-erange path returns EXECUTION_FAILURE (1). rubash returned 1 for both usage shapes. The 5.2.21-vs-5.3.0 question left open on the ticket thread is resolved for the 5.3.0 contract (verified on WSL GNU bash 5.3.0).

#759 item 4 - the three non-bash builtins

  • setopt/unsetopt removed entirely (module, dispatch, classification, completion action table entries): setopt x -> 127 command-not-found, builtin setopt x -> 1 not-a-shell-builtin, enable -a lists exactly GNU's 61 names, option state untouched.
  • compgen -A setopt deliberately untouched - complete.def:130 defines it as a set -o completion action, not the zsh builtin.
  • sudo moves to the hidden-builtin contract (the repo's documented uname/arch pattern): execution keeps the Windows host-capability builtin only while an embedding host registered an elevation handler; with no handler it routes and introspects as the PATH command GNU runs. Introspection (type, command -v, enable -a, compgen -b) reports external unconditionally.

#757 - prompt expansion second pass

The pass now runs the full double-quoted word expansion (parse.y:6689 expand_prompt_string(result, Q_DOUBLE_QUOTES, 0)) instead of a bare-name scanner: bare special parameters ($? $# $$ $- positionals), $((...)), backticks and ${...} operators all expand in ${PS1@P} and the render channels. Gated on promptvars || posixly_correct (parse.y:6683): shopt -u promptvars leaves $var/backtick text literal; posix mode keeps expanding. decode_prompt_string gains the parse.y:6586-6592 \$ contract and the sh_backslash_quote_for_double_quotes protection (syntax.h:26 slashify_in_quotes set) for the \\w \\u \\h \\H \\W \\D{} decode outputs, so their data survives the pass literally.

#431 (\\[ \\] stripping) and #604 (status snapshot, render-path parity) behavior unchanged - issue431/issue604/pb10k/issue393/issue421/issue433 suites all green.

GNU differential evidence (WSL GNU bash 5.3.0, stdin method, 2026-10-18)

facet GNU 5.3.0 rubash before rubash after
( set -- 1 2; shift x ) rc 2 1 2
( set -- 1 2; shift 1 2 ) rc 2 1 2
( set -- 1 2; shift -1 ) rc 1 1 1
shift 99 (3 positionals) rc 1 1 1
command -v setopt rc 1, no output setopt, rc 0 rc 1, no output
command -v unsetopt rc 1, no output unsetopt, rc 0 rc 1, no output
command -v sudo /usr/bin/sudo (external) sudo (builtin) external PATH result
enable -a | wc -l 61 64 61
builtin setopt x / builtin unsetopt x rc 1 0 1
false; PS1='x\$?y' -> \${PS1@P} [x0y] [x\$?y] [x0y]
shopt -u promptvars; PS1='A\$MYVAR B' [A\$MYVAR B] [Axyz B] [A\$MYVAR B]
posix mode + promptvars off [Pxyz S] (expanded) expanded expanded
PS1='c\echo bt`d'` [cbtd] literal backticks [cbtd]
set -- one two; PS1='n\$1 a\$2' [none atwo z] literal [none atwo z]
PS1='m\$((3+4))n' [m7n] ran 3+4 as command [m7n]
PS1='q\"quote\$dollar' (unset) [q\"quote] [q\"quote] [q\"quote]
mkdir 'd\$x'; PS1='\\w' .../d\$x literal literal .../d\$x literal
dirs -l (already fixed on master, 5da6421) one line, space-separated one line one line

Test coverage added

  • tests/regression.rs: shift_bad_operand_status_matches_gnu, zsh_option_builtins_are_gone, sudo_is_not_reported_as_a_builtin
  • tests/issue757_prompt_expansion_regressions.rs: 6 cases (bare specials, promptvars gate incl. render channel + posix override, \$ contract, data quotes, \\w protection)
  • part_057/part_058 shift chain tests move to the 5.3.0 status contract

Full-suite gate

cargo test --release --no-fail-fast -- --test-threads=1 failure set compared bidirectionally against an origin/master worktree run on the same machine and moment: master 44 pre-existing environment failures, this branch 34; every candidate "new" failure was re-run in isolation on both trees and either reproduced identically on master (bashdb trio needs the untracked target/bashdb-clean/bashdb-generated launcher to run at all - with it, master fails the same way) or was the shift-status contract update fixed here. No new failure attributable to the change. Note: arrays/mapfile.rs and part_041.rs carry fmt-only hunks - the pre-commit rustfmt gate rejects any commit while they are unformatted on master.

@caomengxuan666 caomengxuan666 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR verdict: APPROVE-WITH-NITS

Independent review of b6452d3 (PR head == fix/759-757, base 9055c96). All GNU anchors below were re-verified against the vendored 5.3 tree in third_party/bash/; rubash behavior probes were rerun on this machine (Windows release build) and against WSL GNU bash 5.3.0(1)-release.

Verified (per review checklist)

  1. #759 setopt/unsetopt removal — mechanism is a full teardown: src/builtins/zsh_options.rs deleted, pub mod line gone (src/builtins/mod.rs), both dispatch arms removed (command_dispatch_primary.rs, command_no_alias.rs), the execute_zsh_option_builtin helper removed (option_builtins.rs), and classification tables cleaned (builtin_names.rs, command.rs/type.rs is_shell_builtin, command_text.rs env-needs list). grep -r "zsh_options|execute_zsh_option_builtin" src/ tests/ → zero hits; enable setopt → rc 1 "not a shell builtin"; compgen -b lists exactly 61 with no setopt/sudo leak (probed). The enable -a == 61 invariant is pinned cross-platform in tests/regression.rs:2527 (zsh_option_builtins_are_gone) and ALL_BUILTINS in src/builtins/enable.rs is exactly 61 entries. compgen -A setopt retention is correct: third_party/bash/builtins/complete.def:130 { "setopt", CA_SETOPT, 0 } is the set -o completion action (probed: it completes allexport/braceexpand/…, not builtin names).

  2. sudo hidden-builtin contract — routes_as_builtin (src/executor/lookup_paths.rs:93-96) is the single execution-routing gate: cfg!(windows) && "sudo" && elevation_handler.is_some(). Windows-with-handler keeps the host builtin (pre-existing sudo_uses_host_elevation_handler, still green); Windows-without-handler and all unix builds take PATH, verified by code reading of the three gated dispatch arms plus the builtin sudo fall-through to write_builtin_not_found rc 1 (src/executor/builtin_direct_command.rs:301-305). This IS a behavior change for Windows users without an embedding host: sudo cmd previously always answered "elevation handler is not configured" (rc 1); now it runs the PATH command (Win11 System32 sudo.exe where present) or 127 — intended, documented in docs/builtins.md, and strictly closer to GNU (which has no sudo builtin). Coverage gap in F4.

  3. shift statuses — new mapping 2/2/1/1 matches vendored shift.def + builtins/common.c:501-505 (sh_neednumarg, return 0 → EX_USAGE) and common.c:511 (no_args → EX_BADUSAGE). The erange boundary is preserved: negative count → 1 (src/builtins/shift.rs:66) and shift 99 past $# → 1 with the posix/shift_verbose-gated diagnostic (src/executor/shift_echo_builtins.rs:26-47). Grep found no caller depending on the old rc=1 for the two usage shapes — only the three chain tests updated (part_057/058/059), plus untouched erange suites (issue334, part_040) that still pass. New shift_bad_operand_status_matches_gnu pins all four shapes + both diagnostic wordings.

  4. #757 engine — the second pass is now expand_embedded_parameters_inner(_, false, false, false, double_quoted=true): dq-escape set exactly \ $ " + newline-join (matches the Q_DOUBLE_QUOTES contract), quotes are data, bare specials/${}/$((...))/backticks expand. Anchor audit: parse.y:6683 gate ✓, parse.y:6689 expand_prompt_string(result, Q_DOUBLE_QUOTES, 0) ✓, parse.y:6588 \$ euid!=0 backslash ✓ (rubash root branch via EUID==0 matches Windows), parse.y:6430/6434 (\D{}), 6533 (\u), 6545/6549 (\h\H), 6449/6452 (\w\W) quote gating ✓, syntax.h:26 slashify_in_quotes "\\$"\n"✓ and shquote.c:328 newline exemption ✓ — rubash'sprompt_quote_for_expansion set (\ $ ", newline untouched) is exactly this set. Gate priority verified against live GNU: set -o posix; shopt -u promptvars → GNU still expands ([Axyz B]) and so does rubash (pinned in issue757 tests). \w in a $-containing directory stays literal (pinned + probed). " as data ✓. Performance: 20k ${PS1@P} renders of a typical PS1 in ~1s (~50µs/render) — no frame-budget concern; see F6 for the missing benchmark entry.

  5. Differential honesty spot-check — I reran executor_tests on both trees (base = 9055c96 worktree, branch): base 1543 passed/9 failed vs branch 1544 passed/8 failed; failure sets identical (cd/PWD, kill/jobspec, command -P, param +, unclosed-arith-subscript — all environment class), zero branch-only failures; the base-only disappearance (part_071::test_shellmath_decimal_divide_script_path) is favorable-side noise. Candidate new failure drill: regression::upstream_suite_slice_snapshots failed on the branch → rerun on a fresh base worktree → fails there too (pre-existing snapshot/environment class). Claim "no new failure attributable to the change" holds on my sample. Test quality: 3+6+3 new tests each cite GNU probes; issue757 suite is the strongest (gate round-trip, posix override, both channels, \w protection).

  6. Red lines — no GPL text and zero verbatim-C lines in the diff (the only parse.y-adjacent content is prose comments with file:line anchors, all verified against the vendored tree, none mirrored); cargo fmt --check clean; the two fmt-only hunks (src/executor/arrays/mapfile.rs, tests/executor_command_chaining/part_041.rs) are pure rustfmt reflows, no semantic drift; no merge conflicts with current master (base is 10 commits behind, git merge-tree conflict count 0). Temporary review worktree removed; nothing merged.

Findings (nits — none blocking)

  • F1 (minor, new failure mode): prompt-pass expansion errors are not contained. PS1='a${1x}b'; p=${PS1@P}; … now prints bad substitution and aborts the rest of the command list (rc 1, subsequent commands never run) — probed: bash: line 1: a${1x}b: bad substitution, exit 1. GNU 5.3.0 prints the diagnostic but returns the literal a${1x}b with rc 0 and continues (probed on WSL). Pre-PR base was a silent [ab]. The new engine turns malformed prompt content into a command-level fatal expansion error; GNU contains it inside the prompt pass. Unterminated ${b is swallowed ([a]) on both master and this branch while GNU returns the literal — pre-existing, but the same containment fix would cover both. Suggest: catch the diagnostic inside the prompt pass, emit it, and return the decoded text (parse.y behavior), plus a regression probe. src/executor/embedded_parameters.rs:489-492 (the ${} arm's expand_word call) is where the error currently propagates from.

  • F2 (docs accuracy): the ${var?word} boundary is mischaracterized. Commit + PR body say the shape "keeps printing the message text"; observed rubash behavior silently substitutes the message text into the value (pre${MYVAR?msg}post → premsgpost, no stderr) while GNU prints MYVAR: msg and returns the literal. Pre-existing on master (probed base binary), but the declaration doesn't match observable behavior and nothing pins it.

  • F3 (pre-existing, adjacent to touched code): ${PS1@P} leaks command-substitution status into $?. PS1='x$(false)y'; p=${PS1@P}; echo $? → 1 (GNU 0 — parse.y:6684-6696 restores last_command_exit_value around the pass). Base behaves identically (pre-existing), but this PR rewires exactly this path (parameter_transforms.rs:416-430) and already snapshots/restores status in expand_prompt_string_mut for #604; the transform channel is the remaining hole.

  • F4 (coverage): the no-handler execution route is unpinned. sudo_is_not_reported_as_a_builtin asserts only the introspection invariant; nothing exercises (a) sudo cmd with no handler actually executing a PATH command (fake sudo on PATH), or (b) builtin sudo without handler → "not a shell builtin" rc 1. Both verified by code reading only. A #[cfg(windows)] twin of the handler test with clear_elevation_handler() + fake PATH entry would pin the two-branch contract the PR is built on.

  • F5 (contract consistency): help sudo still serves the builtin help page (src/builtins/help.rs:272-279, windows-only) while the other hidden builtins have no topic (help uname → "no help topics match"). Pre-existing, but inconsistent with the declared "introspection surfaces report external unconditionally" contract — either disclose it as part of the hidden-builtin docs or align it.

  • F6 (info): no prompt-render benchmark. The second pass now runs the full engine per render; measured ~50µs/render (20k in ~1s), so no practical concern, but benchmarks/ has no prompt entry to guard the 60fps budget against future engine growth.

  • F7 (nit): command_execute.rs:1063 — is_shell_builtin_name(&expanded) || self.routes_as_builtin(&expanded) — the first disjunct is subsumed by routes_as_builtin; harmless redundancy.

Also worth noting for the changelog: the sudo no-handler behavior change on Windows (F-disclosed above) is user-visible and docs/builtins.md covers it, but CHANGELOG.md is not in this diff.

No temporary changes remain in the repo (review worktree removed; branch cr-810 checked out at b6452d3; nothing merged).

@caomengxuan666

Copy link
Copy Markdown
Member Author

CR 快速轮完成(c4ea987e),F1/F2/F5 已修:

F1(must)— 已修。定位同 CR:遍历内的裁决需要围栏 + 两处裁决点补齐。

  • expand_embedded_parameters_double_quoted(@p / ${var@P} 通道)与 expand_prompt_string_mut(交互渲染通道)现在都按 subst.c:4392-4418 围栏:进出快照/恢复四个裁决锁存(parameter_bad_substitution、arithmetic_expansion_error、arithmetic_fatal_error、arithmetic_nonfatal_error),遍历中有任一 false→true 跃迁即回退为原始解码串——诊断照发、值取字面、外围命令 rc 0。
  • 双引号遍历内补了两个此前缺失的裁决点(均只在 prompt pass 生效,普通词路径不动):未闭合 ${body 按 bad substitution 裁决(GNU:a${bad: bad substitution,body collector 现在上报终止位);?/:? 错误操作符按 subst.c:10403-10418 上报({prefix}{name}: {message},message 展开)而不是把 message 替换进值。

F2 — 择"修对齐 GNU"(同上第二裁决点 + 围栏):PS1='er:${nose?bad} t' 现为 stderr nose: bad + 值字面 + rc 0,与 GNU 5.3.0 逐字节一致。

F5 — 已修:删除 windows-only 的 help sudo 手写页(try_windows_help_extension 及 HELP_TOPICS 里的 #[cfg(windows)] "sudo"),help sudo 走 GNU 无主题形(help: no help topics match 'sudo',rc 1)。

GNU 差分证据(WSL 5.3.0,probe-f1/f1b/f1c,五形态全部逐字节对齐):

形态 GNU 修复后 rubash
PS1='a${1x}b'; p=${PS1@P} stderr a${1x}b: bad substitution;rc 0;p=a${1x}b;后续执行 同
PS1='a$((1x))b' arith 诊断;rc 0;字面 同
PS1='a${bad'(未闭合) a${bad: bad substitution;rc 0;字面 同
PS1='er:${nose?bad} t' stderr nose: bad;rc 0;字面 同
PS1='a$((1/0))b' div0 诊断;rc 0;字面 同

新回归:tests/regression.rs::prompt_expansion_failure_contained_like_gnu(rc+字面+stderr 五形态)与 tests/issue757_prompt_expansion_regressions.rs::malformed_braced_parameter_contained_in_prompt_transform(进程内 rc+值)。

验证:issue393/421/431/433/604/757 + pb10k 共 35/35 绿;lib 690 全绿;executor_tests 全量失败集与裁决基线完全一致(仅那 8 个既有环境态 flake,master 同样复现)。F3/F4/F6/F7 未动,等 followup 票。

caomengxuan666 added a commit that referenced this pull request Oct 18, 2026
…rompt_string (CR F1/F2/F5 on #810)

F1 (regression from the #757 prompt pass): a malformed `${...}` inside
PS1 failed the enclosing command (`PS1='a${1x}b'; p=${PS1@P}` -> rc 1,
variable unset). GNU subst.c:4392-4418 expand_prompt_string runs the
expansion with `no_longjmp_on_fatal_error = 1` and RETURNS THE PASSED
STRING on any verdict. The pass now snapshots the expansion-verdict
latches (parameter_bad_substitution, arithmetic_expansion_error,
arithmetic_fatal_error, arithmetic_nonfatal_error) and, when the walk
raised one, restores them and falls back to the decoded prompt text —
diagnostic stands, value literal, enclosing command still rc 0.
expand_prompt_string_mut (the interactive render channel) gets the same
containment around its double-quoted walk.

Two verdict sites were needed inside the double-quoted walk, both
gated on it so ordinary word paths are untouched:
- an unterminated `${body` (GNU 5.3.0: `PS1='a${bad'` prints
  `a${bad: bad substitution`, value literal) — the body collector now
  reports termination (collect_braced_parameter_body);
- the `?`/`:?` error operator REPORTS (subst.c:10403-10418: `{prefix}
  {name}: {message}`, message expanded) instead of substituting the
  message into the value.

F2 resolved by the same change: `${var?word}` inside the prompt pass is
now GNU-aligned (stderr diagnostic + literal value + rc 0) — probed
against WSL GNU 5.3.0 on all five shapes (bad substitution, arithmetic
verdict, unterminated brace, `?` operator, nonfatal division).

F5: `help sudo` drops the windows-only hand-written help page and takes
the GNU no-topics form (`help: no help topics match 'sudo'`), matching
the new contract that introspection never presents sudo as a builtin.

New differential regressions: tests/regression.rs
prompt_expansion_failure_contained_like_gnu (rc + literal + stderr
across the five shapes) and the in-process
malformed_braced_parameter_contained_in_prompt_transform. Prompt
boundary suites (issue393/421/431/433/604/757, pb10k) 35/35 green;
lib 690 green; executor_tests failure set unchanged (the 8 adjudicated
pre-existing environment flakes).
…sh-name builtins, sudo visibility) and #757 prompt expansion (bare specials, promptvars gate)

#759 item 3 - `shift` with a bad operand is a usage error (2), not a
plain failure. GNU builtins/shift.def routes a non-numeric operand
through get_numeric_arg (builtins/common.c:501-505 sh_neednumarg,
get_numeric_arg returns 0, shift_builtin answers `return (EX_USAGE)`)
and a surplus operand through no_args (set_exit_status(EX_BADUSAGE));
only the shift-count-erange path stays EXECUTION_FAILURE. rubash
returned 1 for both usage shapes; GNU 5.3.0 gives 2/2/1/1 for
x / 1 2 / -1 / 99 and rubash now agrees (the 5.2.21-vs-5.3.0 question
left open on the ticket thread is resolved for the 5.3.0 contract).

#759 item 4 - GNU bash has no `setopt`/`unsetopt` builtins; a script
probing them to detect zsh must miss. Removed the zsh-compat builtins
(src/builtins/zsh_options.rs and every dispatch/classification arm):
`setopt x` is command-not-found (127), `builtin setopt x` is
not-a-shell-builtin (1), `enable -a` lists exactly GNU's 61 names,
and shell option state is untouched by the unknown names.
`compgen -A setopt` is deliberately UNTOUCHED - complete.def:130
defines it as a `set -o` completion action, not the zsh builtin.

`sudo` moves to the hidden-builtin contract (docs/builtins.md, the
uname/arch pattern): execution keeps the Windows host-capability
builtin only while an embedding host registered an elevation handler;
with no handler it routes and introspects as the PATH command GNU runs
(`command -v sudo` finds /usr/bin/sudo, never a bare builtin name).
Introspection surfaces (type, command -v, enable -a, compgen -b)
report external unconditionally.

#757 - the prompt second pass now runs the full double-quoted word
expansion (parse.y:6689 expand_prompt_string with Q_DOUBLE_QUOTES)
instead of a bare-name scanner: bare special parameters ($? $# $$ $-
positional $1/$2), $((...)) arithmetic and backticks all expand in
${PS1@P} and the render channels. The pass is gated on
`promptvars || posixly_correct` (parse.y:6683), so `shopt -u
promptvars` leaves `$var`/backtick text literal while posix mode keeps
expanding. decode_prompt_string gains the parse.y:6586-6592 `\$`
contract (backslash-quoted for the pass when non-root, bare `#`/`$`
otherwise) and the parse.y:6434/6452/6533/6549/6563 backslash-quote
protection for the \w \u \h \H \W \D{} decode outputs (the
slashify_in_quotes set, syntax.h:26), so their data cannot be misread
as expansion syntax by the pass. #431 (\[ \] stripping) and #604
(status snapshot, render-path parity) behavior unchanged - their
regression suites stay green.

Known boundaries left as-is (pre-existing, out of ticket scope): PS4
does not decode PS1-style escapes, the `${var?word}` prompt-pass shape
keeps printing the message text, and ticket section 3 (PS0 emission,
\! / HISTCMD counters, compgen -A signal inventory).

Differential evidence: WSL GNU bash 5.3.0 stdin probes 2026-10-18
(LF scripts, stdout/stderr split). New regression coverage:
tests/regression.rs shift_bad_operand_status_matches_gnu /
zsh_option_builtins_are_gone / sudo_is_not_reported_as_a_builtin and
tests/issue757_prompt_expansion_regressions.rs (6 cases); the three
shift chain tests move to the 5.3.0 status contract. Full
`cargo test --release -- --test-threads=1` failure set compared
bidirectionally against an origin/master worktree run on the same
machine: 44 pre-existing environment failures on master, 34 on this
branch, no new failure attributable to the change. Two files
(arrays/mapfile.rs, executor_command_chaining/part_041.rs) carry
fmt-only hunks the pre-commit rustfmt gate demands on any commit.
…rompt_string (CR F1/F2/F5 on #810)

F1 (regression from the #757 prompt pass): a malformed `${...}` inside
PS1 failed the enclosing command (`PS1='a${1x}b'; p=${PS1@P}` -> rc 1,
variable unset). GNU subst.c:4392-4418 expand_prompt_string runs the
expansion with `no_longjmp_on_fatal_error = 1` and RETURNS THE PASSED
STRING on any verdict. The pass now snapshots the expansion-verdict
latches (parameter_bad_substitution, arithmetic_expansion_error,
arithmetic_fatal_error, arithmetic_nonfatal_error) and, when the walk
raised one, restores them and falls back to the decoded prompt text —
diagnostic stands, value literal, enclosing command still rc 0.
expand_prompt_string_mut (the interactive render channel) gets the same
containment around its double-quoted walk.

Two verdict sites were needed inside the double-quoted walk, both
gated on it so ordinary word paths are untouched:
- an unterminated `${body` (GNU 5.3.0: `PS1='a${bad'` prints
  `a${bad: bad substitution`, value literal) — the body collector now
  reports termination (collect_braced_parameter_body);
- the `?`/`:?` error operator REPORTS (subst.c:10403-10418: `{prefix}
  {name}: {message}`, message expanded) instead of substituting the
  message into the value.

F2 resolved by the same change: `${var?word}` inside the prompt pass is
now GNU-aligned (stderr diagnostic + literal value + rc 0) — probed
against WSL GNU 5.3.0 on all five shapes (bad substitution, arithmetic
verdict, unterminated brace, `?` operator, nonfatal division).

F5: `help sudo` drops the windows-only hand-written help page and takes
the GNU no-topics form (`help: no help topics match 'sudo'`), matching
the new contract that introspection never presents sudo as a builtin.

New differential regressions: tests/regression.rs
prompt_expansion_failure_contained_like_gnu (rc + literal + stderr
across the five shapes) and the in-process
malformed_braced_parameter_contained_in_prompt_transform. Prompt
boundary suites (issue393/421/431/433/604/757, pb10k) 35/35 green;
lib 690 green; executor_tests failure set unchanged (the 8 adjudicated
pre-existing environment flakes).
…cross-target E0609)

routes_as_builtin referenced the #[cfg(windows)] elevation_handler field
unconditionally, so every unix compile lane (linux/darwin/android cross
check, unix Rust tests, shell functionality build) failed with E0609 at
lookup_paths.rs:95. The field and its whole machinery are windows-only
by the established pattern (executor/mod.rs:1039-1040, init.rs:424,
command_substitution.rs:1573, sudo_builtin module gate), so the routing
helper gets the same two-variant shape: on Windows the table plus the
handler-gated sudo arm; elsewhere the pure table - which is also the
GNU-correct answer, since off Windows there is no sudo builtin at all.

The issue757 backslash-dollar decode regression test asserted the root
render (hash); unix CI runs non-root, so it now derives the expectation
from EUID and asserts the literal-name contract on either branch (root
hash / non-root backslash-quoted dollar).
…item 3)

The upstream-suite errors slice pinned the pre-#759 `shift` usage status:
`after shift: 1` twice, recorded while rubash answered EX_USAGE-shaped
failures with EXECUTION_FAILURE. The 5.3.0 contract this branch ships
(builtins/common.c:501-505 get_numeric_arg -> shift.def
`return (EX_USAGE)`, surplus operands through no_args EX_BADUSAGE) is 2,
byte-verified against WSL GNU bash 5.3.0. Re-recorded per the documented
protocol (RUBASH_REGRESSION_RECORD=1 cargo test --test regression
upstream_suite_slice_snapshots); the diff is exactly the two shift lines,
no other slice moved.
@caomengxuan666

Copy link
Copy Markdown
Member Author

CI 两类已清(rebase + E0609 全量修),5892b6fb 已推:

① E0609(must)— 一次清完。CI 四 lane 日志的错误点只有一处(lookup_paths.rs:95:57,routes_as_builtin 无 cfg 门引用 windows-only 的 elevation_handler)。为兑现"不要修一处等下一处",本机装齐 CI 同款四个 target(x86_64-unknown-linux-gnu / aarch64-apple-darwin / aarch64-linux-android / armv7-linux-androideabi)后按 CI 同款命令全量枚举:

  • cargo check --target <4 targets>:0 error
  • cargo check --tests --target x86_64-unknown-linux-gnu / aarch64-apple-darwin:0 error(--tests 把全部测试目标连同新增回归一起编译)

修法按既有 windows-only 模式(executor/mod.rs:1039 字段、init.rs:424、command_substitution.rs:1573、sudo_builtin 模块门全链一致)拆成双变体:windows = 纯表 + handler 门的 sudo 臂;非 windows = 纯表——这也是 GNU 正确答案,unix 上本就没有 sudo builtin。registry 面复审:调度臂(dispatch_primary/no_alias/builtin_direct)均 #[cfg(windows)]、sudo_builtin 模块门已存在、enable/type/command/help/complete 表里 sudo 已整体移除——除 routes_as_builtin 外无其它 unix 可见引用(四个 target 全量 check 证实)。

顺带:issue757 的 \$ 回归断言原钉死 root 形(#),unix CI 非 root 会红——已改为按 EUID 推导期望(root # / 非 root \$ 字面),两分支都断言"名字不展开"。

② goldens — 已愈。rebase 到 8ab35e89(含 #808)无冲突(nquote.snap 未与本分支交集,master 版本原样保留)。goldens 唯一红点是 errors.snap 里两行 after shift: 1——那是本分支 #759 item 3 行为修复(EX_USAGE=2)的预期字节变化,按 job 文档协议 RUBASH_REGRESSION_RECORD=1 重录(diff 恰好只有那两行,其余 slice 未动),cargo test --test regression 全量 74/74 绿。

本机 Windows:lib 690、issue757 7/7、executor_tests shift/setopt 切片 15/15 全绿。CI 判。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant