Repository navigation
fix(cd): announce the verbatim CDPATH join under -P (Refs #3395) - #3531
Merged
Merged
Conversation
GNU builtins/cd.def:370 prints `no_symlinks ? temp : the_current_working_directory`, where temp is cd.def:360's sh_makepath(unit, dirname) join (lib/sh/makepath.c:66). Under -P the announcement is that join verbatim, so a relative CDPATH unit echoes a relative path and `./`/`..` components stay; rubash routed it through the logical destination and absolutized it. The join is now built textually (unit + `/` unless the unit ends in one + operand) instead of Path::join, whose separator is the host's. Also rustfmt tests/d11_pipeline_squote_carrier_regressions.rs, which landed unformatted on master (#3511) and fails the pre-commit check. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
caomengxuan666
marked this pull request as ready for review
November 14, 2026 04:52
caomengxuan666
marked this pull request as draft
November 14, 2026 05:09
caomengxuan666
added a commit
that referenced
this pull request
Nov 14, 2026
…2847) (#3556) Fixes #2847 ## 修了什么 `scripts/check-api-ledger.py` 的 §6 校验从「子树里有同名声明」改为「记录的路径就是真实导出路径」: - `item rubash::a::b::Name`:从 `src/lib.rs` 起逐段解析,每一段必须是 `pub mod`(内联或文件,含 `#[path]`)或把模块 `pub use` 出来的再导出;末段 `Name` 必须在该模块**顶层**以 `pub` 声明(fn/struct/enum/trait/type/const/static/union/mod),或被该模块 `pub use` 再导出(具名、`as` 改名、glob;glob 目标可以是私有模块,如 `parser` 的 `pub use nodes::*`)。只认裸 `pub`,`pub(crate)` 不算对外面。 - `variant` / `method`:其所属类型路径按同一解析器校验(此前 method 完全不看类型路径)。 - 诊断区分两种失败:`declared in the tree but not exported under rubash::…`(路径错)与 `not found in tree`(符号没了)。 - 源码级近似:先抹掉注释与字符串/字符字面量,再按花括号深度判定「顶层」;不追宏生成的条目(真遇到会大声失败、需人工处理)。 - 自检(`--self-test`)新增一组:真实导出路径(具名/改名/私有模块 glob/`#[path]`/根再导出/子模块路径)必须过;未再导出、穿私有模块、类型路径错的 item/variant/method 必须各自失败。 ## 删了什么 `item_exists` 原先的「模块子树 rglob + 声明模式」判定(即 issue 所说的盲区)。`PUB_DECL_PATTERNS` 只保留用于失败诊断(区分「路径错」与「不存在」)。 ## 依据 工程面,无 GNU 锚。 ## 验证 - issue 复现:取 #2850 之前的树(`4f0d493c~1`,`CandidateKind` 尚未在 `src/api/mod.rs` 再导出): - 旧脚本:`all 279 ledger symbols present`,rc=0(假绿) - 新脚本:5 条失败(`item rubash::api::CandidateKind` + 4 个 variant,均为 `declared in the tree but not exported under rubash::api::CandidateKind`),rc=1 - 当前 master:`all 287 ledger symbols present`,rc=0;`--niu D:/repo/niubash`:287 present、97 consumed paths recorded,rc=0。 - `--self-test` rc=0(四段自检全部通过)。 - 运行时间与旧脚本持平(约 13.5s,瓶颈仍是原有的 method 全树扫描)。 - 另带一个仅格式化提交:`tests/d11_pipeline_squote_carrier_regressions.rs`(#3511 在 master 留下的 fmt 漂移,pre-commit hook 必红;与 #3531/#3547 中的同一 hunk 相同,合并无冲突)。 ## Owed - `docs/api-ledger.md` §5 第 1 条仍写「proves presence by declaration patterns only」,现已不准确;但该文件要求与 niubash 副本逐字节相同(canary `cmp`),需 rubash/niubash 成对改,本 PR 未动。 - 未在 CI(`niu-canary.yml` 的 `ledger` / `pairing` job)上实跑,仅本地 Windows Python 3 运行。 ## 队长复核(合入时) - 判词 PASS:L1–L8 一手跑过全绿(287/287、--self-test、复现树双向对照旧假绿 279 / 新 5 缺失、--niu 97 consumed、两份账本 sha256 identical)。 - CI run 43560449915:3 fail 逐名 = issue2875 ×2(goldens、macOS)+ issue2859 Linux-only;issue2859 按 #3292 类确认为 VOID(同头 macOS/goldens 该 cell 绿、零 Rust 产品代码、不碰 jobs/sleep 面)。 - 交集 ∅(merge-base 8b48c16 = live tip),无需 update-branch。 - 合入体:接受正文 Fixes #2847,#2847 随合入自动关闭。
Member
Author
|
【WIN-AGENT-AUDIT】 PR #3531 第1轮 — 建议:PASS 机制核查:
腿:
F 点:无 未跑/VOID 的腿:
|
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.
Fixes #3395
修了什么
cd -P经 CDPATH 条目命中时的回显:GNU 回显sh_makepath(条目, 参数)的原样拼接(相对条目即相对回显,./、..原样保留,绝对条目里的./也保留);rubash 把它经逻辑目的地绝对化/规范化了。$PWD两壳本就一致,分歧仅在回显串。src/builtins/cd.rsresolve_cdpath:命中路径按sh_makepath语义文本拼接(条目 +/(条目已以/结尾则不加)+ 参数原样),不再用Path::join(Windows 上分隔符是\)。该串同时是 chdir 目标与 -P 回显,与 GNU 的temp一致。PrintPath::CdPath回显:Mode::Physical打印该拼接串原样;Mode::Logical维持打印新逻辑 cwd(绝对、规范化)。删了什么
logical_destination_display绝对化的那条路([bug]cd -Pvia CDPATH echoes the resolved physical path instead of the found logical path #1329 修法只把物理目录换成了逻辑目的地,本单是其相对条目轴的 follow-up)。附带:
tests/d11_pipeline_squote_carrier_regressions.rs在 master(#3511)以未格式化形态合入,pre-commit 的 rustfmt 检查因此失败;本 PR 对该文件跑了 rustfmt(纯格式,无语义变化)。GNU 依据
builtins/cd.def:360temp = sh_makepath (path, dirname, MP_DOTILDE);builtins/cd.def:370if (opt && (path = no_symlinks ? temp : the_current_working_directory)) printf ("%s\n", path);—— -P 打印temp,-L 打印新 cwd。lib/sh/makepath.c:66 sh_makepath():path+/(s[-1] != '/'时)+dir,原样拼接;空条目为.。验证
GNU 5.3.20(WSL
/usr/local/bin/bash)脚本文件探针逐形实测,期望写入回归钉tests/issue3395_cd_physical_relative_cdpath_echo.rs(5 个测试;符号链接一例#[cfg(unix)]):cargo test --test issue3395_cd_physical_relative_cdpath_echo同族 stem(Linux/WSL 全绿;这些多为
#[cfg(unix)]):issue2211 14/14、issue2219 9/9、issue2391 6/6、issue2796 12/12、issue3076 24/24、issue3196 6/6、issue3268 19/19、issue3335 15/15。Windows 上 issue392 6/6;issue2211 3/13、issue2219 7/9、issue2391 0/6 在 Windows 上修前修后同值(预先存在的环境失败,与本改动无关)。cargo test --lib builtins::cd5/5。Owed
CDPATH条目以~开头时的MP_DOTILDE波浪号展开未探、未动。