Skip to content

fix(interpreter): propagate errexit_suppressed through compound commands#868

Merged
chaliy merged 2 commits intomainfrom
fix/issue-867-set-e-nested-cfor
Mar 27, 2026
Merged

fix(interpreter): propagate errexit_suppressed through compound commands#868
chaliy merged 2 commits intomainfrom
fix/issue-867-set-e-nested-cfor

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Mar 27, 2026

Summary

  • Add errexit_suppressed flag to ExecResult to track when a non-zero exit code came from an AND-OR list
  • Set the flag in execute_list when the list has conditional operators (&&/||) and exits non-zero
  • Propagate the flag through execute_for, execute_arithmetic_for, and execute_condition_loop (while/until)
  • Skip errexit in execute_command_sequence_impl when the flag is set

Closes #867

Test plan

  • set_e_and_list_in_nested_cfor — nested C-style for loops with [[ ]] && cmd
  • set_e_and_list_in_nested_for_in — nested for-in loops
  • set_e_and_list_in_nested_while — nested while loops
  • set_e_exits_on_plain_failure_in_nested_loop — plain false still triggers errexit
  • All existing set_e_and_or_tests still pass
  • Full test suite passes (cargo test --all-features)
  • cargo fmt --check and cargo clippy clean

@chaliy chaliy force-pushed the fix/issue-867-set-e-nested-cfor branch 2 times, most recently from 76009ba to 30c6116 Compare March 27, 2026 17:49
When a loop body's last command is an AND-OR list (e.g. `[[ cond ]] && cmd`)
that exits non-zero, the loop should not trigger `set -e` at the caller level.

Add `errexit_suppressed` flag to ExecResult. Set it when execute_list returns
a non-zero exit from an AND-OR chain. Propagate it through for, while/until,
and C-style for loops back to execute_command_sequence_impl, which now skips
errexit when the flag is set.

Closes #867
@chaliy chaliy force-pushed the fix/issue-867-set-e-nested-cfor branch from 30c6116 to 0440c3e Compare March 27, 2026 17:57
Add exemptions for cmake 0.1.57, console 0.15.11, insta 1.46.3,
simd-adler32 0.3.8, and unicode-segmentation 1.13.1 alongside the
existing exemptions for their newer versions.

These older versions are in Cargo.lock and need exemptions for
cargo-vet to pass in CI.
@chaliy chaliy force-pushed the fix/issue-867-set-e-nested-cfor branch from 7855104 to 2493fda Compare March 27, 2026 20:40
@chaliy chaliy merged commit 16c6d65 into main Mar 27, 2026
23 checks passed
@chaliy chaliy deleted the fix/issue-867-set-e-nested-cfor branch March 27, 2026 20:47
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.

bug: set -e triggers on [[ ]] && cmd inside nested C-style for loops

1 participant