Skip to content

[BUG] set -e still fires inside a function/group/eval body called from a tested context (f || handler) #259

Open

Description

@strandly-the-agent

Checks

  • I have updated to the latest minor and patch version of Strands Shell (built from main)
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Binding

Rust

Strands Shell Version

main @ origin/main as of 2026-11-12 (crate version 0.0.0)

Language Runtime Version

Rust 1.100.0

Operating System

Amazon Linux 2023 (aarch64)

Installation Method

built from source

Steps to Reproduce

strands-shell -c 'set -e; f() { false; echo in-f; }; f || echo caught; echo after'
strands-shell -c 'set -e; { false; echo in-grp; } || echo caught; echo after'

Expected Behavior

Bash disables errexit for the whole body of a command that runs on the left of ||/&&, after !, or as an if/while condition:

in-f
after

and

in-grp
after

Actual Behavior

  • Function: prints caught, after: the body stops at false.
  • Brace group: prints nothing and exits 1: the || handler never runs.

The tested flag that suppresses errexit (src/exec.rs:2181) isn't carried into function, group, eval or source bodies.

Additional Context

#207 tracks this area. #232 makes assignment-only commands return their substitution's status, which is correct, but it means this bug now also hits the common x=$(cmd) shape. These scripts worked on main only because the assignment always returned 0:

set -e; f() { x=$(false); echo in-f; }; f || echo caught      # bash: in-f   | with #232: caught
set -e; { x=$(false); echo in-grp; } || echo caught           # bash: in-grp | with #232: no output, rc=1

Possible Solution

Carry the tested-context state into nested execution (function calls, { }, ( ), eval, .), so errexit is suppressed for the whole body, not just the top-level item.

Related Issues

#207, #232

Activity

  1. added
    bug
    on Nov 12, 2026
  2. added a commit that references this issue on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Fields

    Language

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions