Repository navigation
fix(executor): anchor bind -f / history file operands at the session cwd (Refs #3090) - #3114
Merged
Merged
Conversation
…on cwd (Refs #3090) tests/issue3090_relative_operand_session_cwd.rs: 9 cells — cd-then- relative bind -f (incl. $include), history -r/-n (operand and $HISTFILE default), -w/-a landing in the session cwd, plus absolute-operand and diagnostic-spelling guards. GNU: builtins/bind.def:274 (rl_read_init_file opens the operand verbatim); builtins/history.def:273,295-316 (the filename is handed verbatim to read_history / write_history / maybe_append_history). On pristine base 95ba591 the pin reads 4 passed / 5 failed: the 5 defect cells red, the 4 guard cells green.
…cwd (Refs #3090) Both builtins opened a relative filename against the process cwd. GNU's single cwd is the session cwd (builtins/bind.def:274; builtins/history.def:273,295-316), so after `cd` the operand missed files sitting in the current directory, and `history -w` silently created its file in the process cwd instead. Route both faces through the one G-02 anchor: the new executor::path::anchored_file_operand composes the spelling translation with anchor_at_session_cwd (the lookup/cd anchor, now pub(crate)); bind -f and its $include reads (lib/readline/bind.c:1502 parser_include) and the history -a/-n/-r/-w opens use the anchored form. Diagnostics keep the as-typed spelling, and the empty operand passes through so its open keeps GNU's ENOENT shape. The host-provider history face in job_builtins.rs is NOT touched: that file is in PR #2968's table (in flight) — see the lane REPORT for the residual. This PR deletes nothing: no code removed; the change is +52/-7 across path.rs, bind_builtins.rs and history_exec.rs, plus the 196-line regression pin in the preceding commit.
This was referenced Nov 9, 2026
# Conflicts: # src/executor/history_exec.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #3090
(车道自报,待队长复核。)
问题与根因
文件操作数型 builtin 在进程内打开用户给的文件名时按进程 cwd 解析相对名,而 GNU 的唯一 cwd 就是会话 cwd:
bind -f(bind_builtins.rs)直接std::fs::read_to_string(file);-a/-n/-r/-w(history_exec.rs)翻译拼写后把相对名原样交给SessionHistory打开。于是
cd之后:bind -f pbind报cannot readrc 1;history -r phist静默 rc 1;history -w whist在进程 cwd 建文件(rc 0、错位落盘)。平名复现,与载体字节无关。GNU 锚点:builtins/bind.def:274(
rl_read_init_file原样打开操作数;$include同路,lib/readline/bind.c:1502 parser_include → bind.c:1079);builtins/history.def:273,295-316(文件名——操作数或 $HISTFILE——原样交给 read_history / write_history / maybe_append_history / read_history_range)。修法(同门同锚定)
src/executor/path.rs:G-02 锚点anchor_at_session_cwd(PATH 查找/cd 一直在用的那个)放宽为pub(crate);新增组合anchored_file_operand= 拼写翻译 + 会话 cwd 锚定,空操作数直通以保住 GNU 的 ENOENT 形状。bind_builtins.rs:-f读取与$include回调读取都走anchored_file_operand。history_exec.rs:四种文件模式的打开走锚定形fs_path;诊断保留翻译后的 as-typedpath不变。本 PR 删除了什么
无删除。3 文件 +52/−7(path.rs +24、bind_builtins.rs +17/−2 面、history_exec.rs +18/−4 面),外加前一提交的回归钉 +196。
未含在本 PR 的同单残余(硬停护栏)
job_builtins.rs(execute_history的 provider 分支把文件名原样交给 host provider):该文件在待合 PR Stage-2 ④ Phase 4: variable-attribute family onto Diag (Refs #2707) #2968 的文件表内,按简报硬停未动,待 Stage-2 ④ Phase 4: variable-attribute family onto Diag (Refs #2707) #2968 合入后补锚。细节与定界见车道 REPORT。script_driver.rs(PTY byte-level ^D exits immediately with stopped jobs, bypassing the EOF deferral (pipe Ok(0) path only) #3051 在飞车道主面),同类未锚,一并记入 REPORT 残余。验证(车道自报,全量日志在 ~/workspace/fix-3090/verify-*.log)
tests/issue3090_relative_operand_session_cwd.rs(9 格):修复树 9/0;移植纯基底95ba59144 过 / 5 红——5 个缺陷格(bind 相对、bind $include、history -r、history -n+$HISTFILE 默认、history -w/-a 落点)全红,4 个守卫格(绝对名 ×2、诊断原文 ×2)双边绿。RUSTFLAGS="-D warnings"、fmt/hygiene/CR:见车道 REPORT 逐腿数字。