Skip to content

refactor(executor): remove the unreachable command-substitution pipeline-filter arms (#710) - #818

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/710
Oct 18, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/710

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Fixes #710

What

Removes the dormant command-substitution pipeline-filter chain, verified unreachable before deletion (issue ask: decide per arm — delete or wire back; decision: delete):

  • command_substitution_pipeline_filter — all 8 filter arms: sort, sed, tr, head, grep, wc, tail, uniq (plus the _ generic-external arm of the same function)
  • command_substitution_pipeline_output (sole caller of the filter)
  • the Some(_) if words.iter().any(|w| w == "|") arm of timed_command_substitution_inner
  • command_substitution_pipeline_first_stage (sole caller: pipeline_output)
  • orphaned helpers: split_pipeline_words, echo_raw_output (+ its unit test)
  • the dead doc-sync test doc_substitution_fastpath_list_matches_substitution_filter_arms + the substitution-fastpath-list machine block in docs/builtins.md

Net: 427 lines deleted, 113 added (new regression test + docs/CHANGELOG).

Per-arm verdicts

arm verdict evidence
sort dead-confirmed-removed 0 probe hits; positive control fires
sed dead-confirmed-removed same
tr dead-confirmed-removed same (dormant tr would fire on time cat f | tr a X; never did on stock build)
head dead-confirmed-removed same
grep dead-confirmed-removed same
wc dead-confirmed-removed decisive dormant signature 1 (one-column -l default) never observed; live path yields GNU three-column 1 1 6
tail dead-confirmed-removed 0 probe hits
uniq dead-confirmed-removed 0 probe hits

No arm was reachable, so no issue-correction was needed; the issue's unreachability proof was confirmed and is in fact stronger than stated — the chain not only requires a | (rejected by command_substitution_body_is_trivial's byte whitelist), it additionally hangs inside the time-prefix shortcut (timed_command_substitution_output returns None unless the body starts with time), so even a gate admitting | would only reach it for $(time … | …) bodies with cat/command/generic first stages.

Unreachability re-verification (before deleting)

  1. Static: sole-caller chain re-derived (filter ← pipeline_output:494 ← timed_inner:585 ← timed_output:521 ← command_substitution.rs:802 behind body_is_trivial:792); alias splicing happens before the gate, so injected | is still rejected.
  2. Runtime negative: entry probes on all three chain links stayed silent across five input batteries — printf/echo/cat producers × all 8 filters, no-space pipes, backtick pipes, nested comsub pipes, time-prefixed, negation, eval, alias-injected |, heredoc-pipe shapes; stdout byte-identical with probes in place.
  3. Positive control: temporarily admitting | in the gate made every probe fire (29 hits) and reproduced the dormant signatures ($(…|wc) → single-column 1; sed/tr arms executing). Control edits fully reverted.

Regression test (the issue's reachability-test ask)

New tests/issue710_comsub_pipeline_reachability.rs pins the routing so a future | shape regressing to "silently ignored pipeline" (#70/#76 family) is caught: wc default three-column, echo-led pipeline not swallowed as literals, all 8 filters through the real executor, time-prefixed pipeline, last-stage status semantics. Every expectation was verified byte-identical against WSL GNU Bash 5.3.0 from a script file.

Verification

  • cargo fmt --check clean; cargo check --all-targets clean (no new warnings in touched files)
  • Full cargo test --workspace --no-fail-fast: baseline (origin/master 8ab35e8) vs this branch — failure sets identical in both directions (43 pre-existing failures; 0 new, 0 fixed); 5377 passed = 5374 baseline + 5 new − 2 dead tests removed
  • Rebased on current master (c6f4a9b); focused tests (builtin_names, new file) green, compile clean
  • PR left unmerged per workflow

GNU anchor: subst.c:7143 command_substitute() routes every substitution body through parse_and_execute — there are no word-level substitution shortcuts upstream, so removal restores the sanctioned rubash#117 shape (fast path only where the body is provably trivial).

…ine-filter arms (#710)

command_substitution_pipeline_filter (sort/sed/tr/head/grep/wc/tail/uniq)
and its only caller chain — command_substitution_pipeline_output, the `|`
arm of timed_command_substitution_inner, command_substitution_pipeline_
first_stage, and the orphaned helpers split_pipeline_words/echo_raw_output —
are unreachable: command_substitution_body_is_trivial admits only
[A-Za-z0-9 \t_-+=.,/:@%^], so no body that can reach the chain can contain
a pipeline, and the chain additionally hangs inside the time-prefix shortcut
(a body must start with `time` to even be considered). GNU subst.c:7143
command_substitute() routes every substitution body through
parse_and_execute — there are no word-level substitution shortcuts
upstream, so removal restores the sanctioned rubash#117 shape.

Runtime re-verification: entry probes on all three chain links stayed
silent across producer x filter batteries (incl. backtick, nested comsub,
alias-injected |, cat/generic first stages); a positive control admitting
| in the triviality gate fired every probe and reproduced the dormant
one-column `wc` default. Observable $( ... | ... ) behaviour is unchanged —
it already ran the real executor's pipeline (pipeline_exec.rs) or the
external binaries.

Also drop the orphaned doc-sync test and the substitution-fastpath-list
machine block, note the resolution in the fast-path audit doc, and pin the
routing with tests/issue710_comsub_pipeline_reachability.rs (expectations
byte-identical to WSL GNU Bash 5.3.0). Full failure set identical to the
origin/master baseline in both directions (43 pre-existing failures, 0 new,
0 fixed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

command_substitution_values.rs pipeline-filter arms are unreachable (dead) and carry the carrier defects

1 participant