Repository navigation
refactor(executor): remove the unreachable command-substitution pipeline-filter arms (#710) - #818
Merged
Merged
Conversation
…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).
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 #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)Some(_) if words.iter().any(|w| w == "|")arm oftimed_command_substitution_innercommand_substitution_pipeline_first_stage(sole caller:pipeline_output)split_pipeline_words,echo_raw_output(+ its unit test)doc_substitution_fastpath_list_matches_substitution_filter_arms+ thesubstitution-fastpath-listmachine block indocs/builtins.mdNet: 427 lines deleted, 113 added (new regression test + docs/CHANGELOG).
Per-arm verdicts
sortsedtrtrwould fire ontime cat f | tr a X; never did on stock build)headgrepwc1(one-column-ldefault) never observed; live path yields GNU three-column1 1 6tailuniqNo 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 bycommand_substitution_body_is_trivial's byte whitelist), it additionally hangs inside thetime-prefix shortcut (timed_command_substitution_outputreturns None unless the body starts withtime), so even a gate admitting|would only reach it for$(time … | …)bodies withcat/command/generic first stages.Unreachability re-verification (before deleting)
filter←pipeline_output:494←timed_inner:585←timed_output:521←command_substitution.rs:802behindbody_is_trivial:792); alias splicing happens before the gate, so injected|is still rejected.printf/echo/catproducers × 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.|in the gate made every probe fire (29 hits) and reproduced the dormant signatures ($(…|wc)→ single-column1;sed/trarms executing). Control edits fully reverted.Regression test (the issue's reachability-test ask)
New
tests/issue710_comsub_pipeline_reachability.rspins the routing so a future|shape regressing to "silently ignored pipeline" (#70/#76 family) is caught:wcdefault 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 --checkclean;cargo check --all-targetsclean (no new warnings in touched files)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 removedbuiltin_names, new file) green, compile cleanGNU anchor:
subst.c:7143 command_substitute()routes every substitution body throughparse_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).