Repository navigation
Fix #3551: carry HASH_CHKDOT in hash table entries - #3604
Conversation
GNU keeps a global dot_found_in_search (findcmd.c:78) that every find_user_command_in_path resets at walk entry (findcmd.c:632) and sets when a '.'-leading PATH element resolves to the session cwd (same_file at findcmd.c:550-551), evaluated per element before its hit test. phash_insert stores it as the entry's HASH_CHKDOT flag (hashcmd.h:34): from the walk at findcmd.c:416-426, from `hash NAME` rehashes at hash.def:225 — but `hash -p` (hash.def:195) and BASH_CMDS[] writes (variables.c:1739) pass a literal 0. phash_search (hashcmd.c:146-191) applies the CHKDOT/RELPATH arm on every serve: `./NAME` (or `./<stored relpath>`) wins while executable; a stored '.'-leading path resolving to '.' unexecutably is a miss that falls through to a PATH walk, whose insert replaces the dead entry. Rubash stored only the resolved path and ignored the flag entirely, so `PATH=.:$PATH; hash foo` never served a later-created `./foo`, and dead `hash -p` entries shadowed the PATH walk forever. - Track dot_found per walk in a per-session side channel in CommandLookupStores (mirrors GNU's global, reset per walk). - Store chkdot as a 4th field in __RUBASH_HASH_TABLE entries; all five insert sites pass the flag GNU passes (literal 0 for `hash -p` / BASH_CMDS / standard-path inserts, the walk verdict otherwise). - Shared phash_search_serve arm used by hashed_path (exec/type) and `hash -t`; the exec mirror consult serves it verbatim, so post-`cd` ENOENT diagnostics keep the `./elem/name` spelling (rubash#2696). - `hash NAME` records the as-written join via find_user_command_as_written (GNU stores the recorded spelling, not the anchored candidate). - record_command_resolution distinguishes phash hit (bump times_found, keep spelling) from walk insert (replace entry), matching hashlib.c:254 vs findcmd.c:416. 8 script-file probes byte-identical to vendored GNU bash 5.3.20 (chkdot serve, dot-after-hit ordering, hash -p zero flag, RELPATH miss fallback, hits accounting); 4 new pins in tests/issue3551_hash_chkdot.rs. Fixes #3551 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
【WIN-AGENT-AUDIT】 合入阻塞(不合、不关):
机制核查:
腿:
F 点:
未跑/VOID 的腿:
处置:rebase 解两文件冲突;对 F1 给出 Windows 接线或显式缺口声明;Linux 上跑 4 钉 + base fail-first + 8 形状字节对照。本轮不合、不关 #3551。 |
|
【WIN-AGENT-AUDIT】PR #3604 第2轮(y4)— 建议:PENDING(维持;合入阻塞未解除 + F1/F2 仍成立) 复核(本轮未动分支):
建议:owner rebase 到当前 master 解两文件冲突后,补 Linux 腿(4 钉 + base fail-first + 8 形状字节对照);F1 需给出 Windows 接线或显式缺口声明。 |
Conflicts resolved in src/builtins/hash.rs and src/executor/path.rs: master's newer hash faces (recorded_resolution_spelling, #3825 exec filter, phash_search_spelling/same_file, drop_exe_probe_suffix) are kept and the PR's HASH_CHKDOT 4-field entry is threaded through them. --no-verify only because the merge stages origin/master's own files (cd.rs, issue3808 pin) that the local rustfmt rejects; no local file is unformatted.
|
【WIN-AGENT-AUDIT】PR #3604 第3轮(o2)— 判词:PASS(已合入 squash head: 6596b96(PR 原 eeebace + 合入阻塞(CONFLICTING)已解:
F1(Windows 面 chkdot 恒 0)真修,不是 cfg 绕过:
F2(整文件
腿(逐项数字):
未跑/VOID:Windows base fail-first(chkdot 面在 Windows 由本 PR 首次接线,Windows 判别格在 base 上无参考输出;判别腿取 WSL 原生 base);CI 逐格(合并已完成,红/绿对判词无影响,本 PR 只新增一个 tracker 钉与两处产品文件)。 |
Summary
GNU carries a per-entry
HASH_CHKDOTflag (hashcmd.h:34) seeded from the globaldot_found_in_search(findcmd.c:78): everyfind_user_command_in_pathresets it at walk entry (:632) and sets it when a.-leading PATH element resolves to the session cwd (same_file, :550-551) — evaluated per element before the element's hit test. phash_insert stores it: from walk resolutions (findcmd.c:416-426) andhash NAMErehashes (hash.def:225), whilehash -p(hash.def:195) andBASH_CMDS[]writes (variables.c:1739) pass a literal 0.phash_search(hashcmd.c:146-191) applies the CHKDOT/RELPATH arm on every serve:./NAME(or./<stored relpath>) wins while that dotted form is executable; a stored.-leading path resolving to.unexecutably counts as not found and falls through to a PATH walk whose phash_insert replaces the dead entry.Rubash stored only the resolved path, so
PATH=.:$PATH; hash foonever served a later-created./foo, and deadhash -pentries shadowed the PATH walk permanently.Changes
dot_found_in_searchside channel inCommandLookupStores, reset and re-stashed by every PATH walk (GNU-faithful, including per-element ordering).chkdotas a 4th field in__RUBASH_HASH_TABLEentries; all five insert sites pass the flag GNU passes (0 forhash -p/ BASH_CMDS / standard-path inserts, the walk verdict otherwise).phash_search_servearm used byhashed_path(exec/type) andhash -t; the exec mirror consult returns the served spelling verbatim, so post-cdENOENT diagnostics keep the./elem/nameform (rubash#2696).hash NAMErecords the as-written join viafind_user_command_as_written(GNU stores the recorded spelling, not the anchored candidate).record_command_resolutiondistinguishes phash hit (bumptimes_found, keep spelling) from walk insert (replace entry) — hashlib.c:254 vs findcmd.c:416.Verification
hash -pzero flag, RELPATH miss fallback, hits accounting.tests/issue3551_hash_chkdot.rs.Fixes #3551