Repository navigation
fix(executor,cd): bare drive designator D:/cd D: converge on the engine dispatch - #953
Conversation
…ne dispatch (unixwin/niubash#481, refs unixwin/niubash#483) The product REPL's Windows normalizers (niubash-runtime shell.rs normalize_bare_windows_drive_commands / normalize_cd_windows_drive_args) run only on the interactive host fast path — below the batch gate's early return. The grouped reader (D:; pwd / cd D: && pwd), the engine's piped -i stdin driver, and every nested context the AST pass does not descend into (function bodies, eval) handed the bare word to the executor, which reported `D:: command not found` / `cd: D:: No such file or directory` — one keystroke of intent, two outcomes per reader route. Move the semantics to the two engine funnels every route shares: - execute_command rewrites a bare `X:` node into the same `cd X:/` the host pass emits (executor/windows_drive.rs ports the host predicate verbatim — lone unquoted word, no assignments/redirects/pipes/ background/!/time/compound structure — so admission cannot drift). - cd's operand resolution folds a bare `X:` designator to the `/x/` drive-root spelling the in-shell path funnel already maps (builtins/cd.rs windows_bare_drive_operand); `D:rel` drive-relative forms stay filename data. - shell_pwd_display_path renders the bare `D:` root display as `/d/` (rubash#537 contract) — `cd D:/` previously stranded the designator in $PWD. GNU has no drive designators — no upstream anchor exists; the contract is the product persona the host normalizer already defines, now held at one semantic owner instead of per-route. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
CR(本轮不合并)方案本身验证通过,但 CI 在 PR 自己新增的代码上红了: 门脚本的头注释写明了流程:新 两处位点实际上都是可证安全的——
语义与测试面(本地复验,全绿,附证据)
补两行 ALLOWLIST 或改写后 push,CI 转绿即可合并,无需重跑本轮已验面。 |
… and windows_drive.rs The two `bytes[0] as char` drive-letter folds added for niubash#481/#483 each sit behind a `bytes[0].is_ascii_alphabetic()` condition, pinning the widened byte to ASCII — never a UTF-8 continuation byte. Same reviewed-safe class as the existing path.rs/cd/paths.rs/pwd.rs entries. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
已按方案 1 修复 BLOCKER(8f161cdc):两处 本地复验:
|
终审:通过,合并返工验收四项全过(head
Fixes unixwin/niubash#481 · Refs unixwin/niubash#483 |
Summary
Fixes unixwin/niubash#481 · Refs unixwin/niubash#483
The niubash product REPL applies its four Windows normalizers
(
normalize_bare_windows_drive_commands,normalize_cd_windows_drive_args,normalize_winuxcmd_slash_drive_args,rewrite_winuxcmd_command_shims) onlyon the interactive host fast path — below the batch gate's early return in
shell.rs. Every other read route reaches the executor with the raw text:D:; pwd,cd D: && pwd,alias heads, keywords) — niubash#481;
-istdin driver (run_interactive_stdin), whereniu -iwith a non-terminal stdin lands — niubash#483;eval,$(...), sourced files).Bare-drive forms have no engine-side handling, so they diverged by route:
D:→D:: command not found,cd D:→cd: D:: No such file or directoryon every route except the normalized fast path.
Fix
The bare-drive semantics now live at the two engine funnels all routes share,
so the outcome is identical whether or not a host normalized first:
src/executor/windows_drive.rs(new) —bare_windows_drive_command_rootports the host pass's shape predicate verbatim (lone unquoted
X:word; noassignments, redirects, pipe/background/
!/timemarkers, no compoundstructure) and
execute_bare_windows_drive_commandrewrites the node tothe same
cd X:/triple the host emits (words + kinds + literal metadata),then re-dispatches through
execute_command—$_, xtrace, errexit, anddiagnostics all follow ordinary
cdsemantics. Hooked at the top ofexecute_command_with_procsub_scope.src/builtins/cd.rs—windows_bare_drive_operandfolds a bareX:operand to the
/x/slash-drive root the in-shell funnel already resolves;D:reldrive-relative spellings stay untouched.src/executor/path.rs—shell_pwd_display_pathrenders the bareD:root display as
/d/(rubash#537 persona contract). This also repairs aresidual on the operand path:
cd D:/previously strandedD:in$PWD.GNU has no drive designators, so there is no upstream C anchor to cite — the
contract is the Windows persona the host normalizer already defines; this
moves it to a single semantic owner instead of per-route normalization.
Convergent scope notes:
D:stays command-not-found inside pipelines(
D: | cat,true | D:), quoted ("D:"), with args/assignments/redirects —matching the host pass's exclusions.
D: &,! D:,time D:now resolve tothe drive switch inside their wrapper (the exclusion cannot survive the
engine respawn/re-entry boundary), which keeps all routes identical. The
slash-drive arg normalizer and winuxcmd shim rewrite remain host-side and are
out of scope (niubash#483 stays open).
Test plan
tests/issue481_bare_drive_command_regressions.rs(4 tests):D:/cd D:under;and&&,$PWD/OLDPWDpersona form, functionbody +
evalcontexts, piped-istdin driver, and thecommand-not-found exclusion matrix.
cargo test --lib— 745 passed.cargo test --test path_contract_boundary_posix_forms --test path_contract_boundary_native_core --test issue566_bare_drive_root_enoent_regressions --test issue359_colon_redirect_regressions— all pass.cargo test --test executor_tests— 1552 passed; the 6 failures arepre-existing on clean master at this worktree base (missing
third_party submodule content + host PATH/env dependent cases),
verified by stashing and re-running.
D:; pwd→/d/;cd D: && pwd→/d/;printf 'cd D:\npwd\n' | rubash -i→/d/.Generated with Devin