Skip to content

[BUG] command -v ignores redirects, so command -v X >/dev/null still prints X #294

Done

Description

@strandly-the-agent

Checks

  • I have updated to the latest minor and patch version of Strands Shell
  • 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 @ 5f80040 (also reproduces on PR #269 head 804c7bf)

Language Runtime Version

n/a (built from source with the repo's toolchain)

Operating System

Linux aarch64

Installation Method

built from source

Steps to Reproduce

strands-shell -c 'if command -v ls >/dev/null 2>&1; then echo have-ls; fi'
strands-shell -c 'command -v cd > /tmp/x; cat /tmp/x'

Expected Behavior

As in dash/bash: the first prints only have-ls; the second writes cd into /tmp/x and cat prints it.

Actual Behavior

ls
have-ls

and for the second, cd goes to stdout, /tmp/x is never created, and cat fails with no such file or directory: /tmp/x. Exit statuses are correct, so if command -v X ... still branches right; the problem is the extra stdout output.

Additional Context

command -v NAME >/dev/null 2>&1 is the standard way agents probe for a tool, and PR #269 tells models to use command -v from the MCP tool description, so this noise will show up in their output.

Cause: src/exec.rs:3117-3158 handles command -v/-V inline and writes with proc.out_msg(...), but never applies pipeline[0].redirects. A few lines above, the exec branch keeps them (redirects: pipeline[0].redirects.clone()).

Possible Solution

Apply the simple command's redirects around the command -v output, or route command -v through the normal builtin dispatch so redirects and pipelines work the same way they do for other builtins.

Related Issues

#207, #269, #272 (which, "resolved like command -v")

Activity

  1. added
    bug
    on Nov 13, 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