Repository navigation
fix(executor): #846 - ! no longer flips a compound's own redirect failure - #902
Merged
Merged
Conversation
GNU execute_cmd.c:854-883: a compound do_redirections failure returns
EXECUTION_FAILURE before the :1204-1207 invert step, so `! { :; } > /bad`
exits 1 (no flip). Same for `(( ))`, `[[ ]]`, subshell, if/loop/for/
select/case/coproc/time; the pipeline level still always flips (:763).
Port as a leave-set Cell flag `compound_redirect_failed` (mod.rs/init.rs,
fork-copied in command_substitution.rs): every compound-own redirect-open
mark site sets it on IoError only (never ExpansionFailure/failglob);
dispatch flip sites (inverted wrapper, bool path, time sites) suppress the
flip while set; pipeline flip sites always flip and consume; subshell-region
completion flips+consumes iff the single body is inverted; function/eval/
source/comsub/evalerror-depth-1 boundaries clear it.
Two follow-on fixes in this commit:
- `! [[ -n x ]] > /bad` flipped to 0: `[[ ]]` with redirects dispatches
through execute_conditional_command_with_redirects (command_prepare.rs),
never reaching the late.rs word arm that carried the only mark. Mark
added at the live path.
- `! true | cat > /bad` printed the diagnostic then lost ALL later stdout:
the stage redirect preflights propagated Err past an active thread-local
stdout capture without restoring it. Restore before propagating in
execute_pipeline_stage_inner, the builtin stage path, and the
compound-stage failglob early return.
Verified: 10-case WSL GNU Bash 5.3.0 script-file battery (brace/subsh/
if/for/while/cond/arith/pipe/lastelem/and/or/coproc/async/comsub/time
forms - stdout+stderr byte-identical), tests/issue846 (9 tests),
cargo test --test regression 78/78 incl. upstream snapshots. Full
cargo test --no-fail-fast matches the clean-HEAD failure set exactly
(all remaining failures are sandbox-environmental: missing external
coreutils, signal/console limits, timing flakes).
Known follow-up (pre-existing, out of scope): a MIDDLE stage
output-redirect failure aborts later stages (`echo A | cat > bad | cat`
is rc 1, GNU rc 0) - the preflight Err propagation predates this work.
Contributor
|
欢迎!这是你的第一个 PR 🎉 请确认已跑过本地测试套件;CI 通过后维护者会 review。 |
Member
独立评审裁决(#897 vs #902 同票双 PR):建议合入本 PR本 PR 与 #897 同为 closes #846。按双分支自建 worktree 实测裁决:合入 #902,#897 以 superseded 关闭。方法:master / #897 / #902 三树自建构建(6e600e5a / bbf06a0,debug),oracle 为 WSL GNU bash 5.3.0(1),60 形矩阵(52 计划形 + 8 边界探针形)rc+stdout+stderr 逐字节比对(程序名前缀与 time 计时行归一化)。对侧裁决评论见 #897。 本 PR 实测结果60 形中除两处双方共有且预存的面外全部与 GNU 5.3.0 一致:
对照 #897 的实测分歧面(仅列差异形,
判定依据
非阻塞建议
两 PR 在 command_prepare.rs / compound_exec.rs 等九个文件文本重叠:本 PR 合入后 #897 无法干净合入,应关闭而非重排。 |
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.
Closes #846.
Top-level bang over a compound whose OWN redirect open fails must not flip: GNU execute_cmd.c:854-883 returns EXECUTION_FAILURE before the :1204-1207 invert step, so ! { :; } > /bad is rc 1. Same for subshell/if/loop/for/select/case/coproc/time/(( ))/[[ ]]; the pipeline level still always flips (:763).
How:
Verification:
Known follow-up (pre-existing, out of scope): a MIDDLE stage output-redirect failure aborts later stages (echo A | cat > bad | cat is rc 1, GNU rc 0).