Skip to content

[BUG] stderr written inside $( ) is dropped (x=$(ls /missing) prints no error) #370

Open

Description

@strandly-the-agent

Checks

  • I have updated to the latest minor and patch version of Strands Shell (built from main @ dbb6189)
  • 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

dbb6189 (--version prints 0.0.0)

Language Runtime Version

Rust 1.100.0

Operating System

Linux 6.18 (aarch64)

Installation Method

built from source

Steps to Reproduce

strands-shell -c 'x=$(ls /nonexistent-dir); echo "rc=$?"'
strands-shell -c 'x=$(nosuchcmd); echo "rc=$?"'
strands-shell -c 'x=$(echo err >&2; echo out); echo "x=$x"'

Expected Behavior

Same as bash: a command substitution captures stdout only, so stderr still reaches the shell's stderr.

Command stdout stderr
1 rc=2 ls: cannot access '/nonexistent-dir': No such file or directory
2 rc=127 bash: line 1: nosuchcmd: command not found
3 x=out err

Actual Behavior

stdout matches bash in all three, and stderr is empty in all three.

Additional Context

Outside a substitution the message is printed: ls /nonexistent-dir writes the same error to stderr.

A caller that runs out=$(cmd) and sees a non-zero status gets no message saying why.

Found while reviewing #348; it is not caused by that PR. The results are the same on main @ dbb6189 and on #348's head 9ef3e56. I ran debug builds through -c only and compared with bash 5.2.15.

Possible Solution

Not investigated.

Related Issues

n/a

Activity

  1. added
    bug
    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

    Fields

    Language

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions