Repository navigation
fix(executor): restore DATA_SQUOTE carrier on pipeline child-argv boundaries - #3511
Conversation
…ndaries A pipeline member's argument word that mixes a live backtick command substitution with an apostrophe reached the external child's argv with the DATA_SQUOTE carrier (0x17) still encoded: "A `echo AAA` B member's C" | tail -1 handed python argv[1] = 'A AAA B member\x17s C' instead of "A AAA B member's C". The plain-command argv boundary decodes the carrier through materialize_expanded_command_word (command_prepare.rs), but the pipeline spawn faces — the sequential external stage (pipeline_stages.rs) and the concurrent fast path (pipeline_exec.rs concurrent_external_stage_spec / execute_external_ pipeline_concurrently) — only ran restore_command_substitution_output, whose replace chain covers DATA_BACKTICK / DATA_DOLLAR / PROTECTED_BACKSLASH / DATA_BACKSLASH / DATA_DQUOTE and never DATA_SQUOTE. Add the DATA_SQUOTE restore to restore_command_substitution_output itself: every remaining caller that reaches a child-argv boundary needs the same decode, and the internal transport callers (expand_word.rs, command_substitution_values.rs, substitution_metadata.rs) pass through it in flight, where a later boundary (materialize_expanded_command_word or the same restore at argv) still sees the carrier byte it must decode — no double-decode hazard, because every argv materialization point runs the family exactly once. Raw-byte safe: typed 0x17 user data cannot arrive bare (markers.rs raw-byte marker pair on entry), matching the plain-command boundary's .replace decode. GNU: subst.c:11882-11886 (case '\'') copies a single-quoted span verbatim — the child argv gets a real apostrophe. Regressions: tests/d11_pipeline_squote_carrier_regressions.rs (6 cells; all failed on the unfixed tree with \x17 in the child argv).
|
Thanks for the follow-up, @Catapult291 — received and recorded. What I captured: a pipeline member's argument word mixing a live backtick substitution with an apostrophe reached the external child's argv with the CI status, read from the run: three legs are red — Rust tests, Rust tests (macOS), GNU regression goldens and canaries — and all three fail on the same single test, One scope note for review: the change lands in the shared restore helper, so it decodes Per the owner's rule for external PRs, this is queued for captain review; I won't merge or request changes here. CI is being watched. |
队长复核:PASS ✅外部贡献(@Catapult291),队长复核结论如下(复核车道独立核查 + 队长抽查): 缺陷与修法成立。 管道成员参数词里「活反引号命令替换 + 撇号」混排时,外部子进程 argv 收到未还原的 证据:
小注(不挡合入): PR 正文无删除节、无 issue 引用(自引 niubash 缺陷清单 D11)。外部 PR 按证据合入;正文卫生下次请补删除节。 Refs-only 性质:本 PR 不自动关闭任何 issue,队长合入后计数不变。 |
…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 随合入自动关闭。
|
Independent repro from a Pi integration running the shipped Niubash 1.5.0 (
This matches the pre-fix analysis in the PR; the |
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>
…TIMEFORMAT (Refs #3393) (#3537) GNU lib/readline/histfile.c:384 read_history_range arms history_multiline_entries only when the file starts with a timestamp line AND history_write_timestamps is set (variables.c:6177 sv_histtimefmt: HISTTIMEFORMAT exists). The counter is never reset. rubash regrouped whenever the file had timestamps. Model the sticky counter on SessionHistory and feed it the read-time variable state; the interactive startup load takes the same state instead of a hard-wired armed read. The issue1669 pin chained unarmed reads after an armed one in one process, which only matched the old non-sticky model; GNU 5.3.20 regroups there. Split the unarmed phases into fresh processes. Also rustfmt the d11 stem (master drift from #3511) so the fmt hook passes. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…k (Refs #3489) (#3547) * fix(read): re-tag carrier bytes on the C-locale byte-domain write-back (Refs #3489) read_split.rs byte_domain_value emitted every byte < 0x80 as a bare char when it turned single-byte-locale fields back into storage text, undoing tag_read_carrier_text. Under LC_ALL=C (bats runs formatters under env -i) ESC stopped matching $'\e' patterns, so the junit formatter's xml_escape CSI strip left [0m/[K behind; 0x14 became `\`, 0x1f `$`, 0x11/0x13 vanished. The write-back now goes through bytes_to_shell_text, the storage-domain inverse of shell_text_to_raw_bytes, which re-forms UTF-8 and re-tags carriers. GNU: builtins/read.def:838-845 escapes CTLESC/CTLNUL and read.def:1127 / :1061 dequote_string undoes it, so the bound value is byte-identical to the input in every locale. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * style(tests): rustfmt the d11 pipeline squote stem master fmt drift from #3511 makes `cargo fmt --check` (the pre-commit hook and CI fmt) fail on every branch; formatting only, no test change. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… (#3554) * fix(hash): re-validate relative hash entries on every read (Refs #3359) GNU hashcmd.c:126 phash_search is the single read of a remembered location for execution (findcmd.c:365 search_for_command), type / command -v (type.def:353) and hash -t (hash.def:284). For a stored relative path (HASH_RELPATH) it serves the ./-prefixed form when executable and answers NULL when the stored ./path's directory is the cwd and the file is gone (hashcmd.c:146-187), so the lookup re-walks PATH. rubash applied that rule only to hash -t and served the stored spelling unvalidated everywhere else; `hash NAME` also stored the cwd-anchored path instead of the search's as-written join (hash.def:213-225 add_hashed_command). - builtins::hash::phash_search / phash_search_spelling: one shared implementation, probes anchored at the session cwd. - path::find_user_command's hash-mirror consult goes through it; a refused entry drops the stale PATH-scan memo and walks PATH. - type/command -v describe faces read through phash_search. - record_command_resolution overwrites a refused entry (phash_insert, times_found = 1) instead of bumping it. - `hash NAME` records recorded_resolution_spelling and syncs the mirror. 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> * docs(hash): point the unmodelled HASH_CHKDOT arm at rubash#3551 (Refs #3359) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: root <[email protected]>
…3372) (#3565) GNU redir.c:298 redirection_expand gives every redirect its own expanded bytes and redir.c:702 redir_open opens them verbatim, so in `: >"$a" >>"$b"` a raw-byte x<9C> and a genuine x<U+009C> (same folded string) land as two files. #3368 made the create funnel read the redirect-node spelling record; the append funnel still read the folded-string record and reopened the other redirect's spelling. - shell_options: open_append_target_for(Option<&Redirect>, target); every filesystem arm resolves through the node record when a node is given (plain funnel otherwise, never the string-keyed record). probe_output_redirect_append takes the node too, for both its FIFO stat and its open. - builtin_redirects / external_redirects / redirection: the append call sites that hold the node pass it. - mod.rs: correct the field comment that claimed a no-transport outcome clears the string-keyed record (the code never removes it). 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>
…y (Refs #3305) (#3559) read_coproc_stdout compared the delimiter on every byte and counted the -n/-N budget per byte. GNU builtins/read.def:834 compares the stream byte against the first byte of the -d word only at a read_mbchar unit start, and read.def:884-886 counts the budget per completed unit (post-escape). The fd-table serves already replay that loop through FdRecordScan; the coproc serve now drives the same scanner, dropping the delimiter like they do. ReadEscapeTracker (its last user) is gone. Also rustfmt the d11 stem (master drift from #3511) so the fmt hook passes. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…s GNU does (Refs #3457) (#3549) GNU runs every startup file through builtins/evalfile.c:339 maybe_execute_file with FEVAL_ENOENTOK: ENOENT is not diagnosed (evalfile.c:120) and returns 0 (evalfile.c:130); EACCES and other open failures still go through file_error, and a directory is reported as `%s: is a directory` (evalfile.c:133-138). run_init_file diagnosed ENOENT and, on Windows, reported a directory as `Permission denied`. The diagnostic name prefix is untouched (PR #3447 owns it). Also rustfmt the d11 stem (master drift from #3511) so the fmt hook passes. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Summary
A pipeline member's argument word that mixes a live backtick command substitution with an apostrophe reached the external child's argv with the
DATA_SQUOTEcarrier (0x17, U+0017) still encoded — the child received a raw control byte instead of the apostrophe:Root cause: the lexer encodes every
'inside a double-quoted word that also carries a live backtick substitution asDATA_SQUOTE(src/lexer/quotes.rs:208). The plain-command argv boundary decodes it throughmaterialize_expanded_command_word(command_prepare.rs), but the pipeline spawn faces — the sequential external stage (pipeline_stages.rs) and the concurrent fast path (pipeline_exec.rs,concurrent_external_stage_spec/execute_external_pipeline_concurrently) — only ranrestore_command_substitution_output, whose replace chain coversDATA_BACKTICK/DATA_DOLLAR/PROTECTED_BACKSLASH/DATA_BACKSLASH/DATA_DQUOTEand neverDATA_SQUOTE.Changes
DATA_SQUOTE → 'restore torestore_command_substitution_output(execution_misc.rs). The remaining callers that reach a child-argv boundary need the same decode; the in-flight transport callers pass through it and the carrier byte stays decodable at each argv materialization point.0x17user data cannot arrive bare (it rides the raw-byte marker pair on entry), matching the plain-command boundary's existing.replacedecode — same argument the family already relies on forDATA_BACKTICK/DATA_DQUOTE.subst.c:11882-11886(case '\'') copies a single-quoted span verbatim — the child argv gets a real apostrophe.tests/d11_pipeline_squote_carrier_regressions.rs(6 cells). All 6 failed on the unfixed tree with\x17in the child argv; all pass after the fix. Cells cover the full trigger shape, the concurrent fast-path face (| cat), multiple apostrophes, and the non-triggering neighbors ($(), no-pipeline, apostrophe-only) as guards against over-decoding.Trigger elements (diagnosis notes)
$()did not leak through the plain walker's restore);| tail,| cat, …).Test plan
cargo test --test d11_pipeline_squote_carrier_regressions— 6/6 (0/6 before the fix).cargo test --lib— 1349 passed / 1 pre-existing failure (api::consumer_tests::issue2084, fails on master too).marker_leak_golden,marker_registry_roundtrips,issue124_eval_quote_marker,issue1540_pipeline_element_expansion_regressions,issue3058_assignment_comsub_carrier_leak,issue3103_command_word_split_carrier,issue354_carrier_comsub_regressions,issue548_arith_for_carrier_echo_regressions,issue948_pua_carrier_passthrough_regressions,issue2129_startup_carrier_recursion,issue2137_execution_scope_markers,issue2883_read_prompt_carrier_regressions,issue735_pua_marker_collision,pipeline_streaming_regressions— all green.carrier_byte_class_regressions(2 PUA cells),issue3308_comsub_pipeline_stderr_redirects(9 script-mode cells).yes | head -3 2>/dev/null,2>&1,seq 1 100000 | cat | wc -ldata integrity) all clean.Related local defect record: niubash defects list D11 (2026-11-14).