Skip to content

rtk rg --files <path> treats the path as a pattern when stdin is a pipe #4237

Open

Description

@KuSh

rtk rg --files <path> does not read stdin. It still reacts to stdin, though, depending on how the agent's shell set it up:

$ rtk rg --files src/cmds/system </dev/null | head -2
src/cmds/system/ (19 files)
summary.rs
$ : | rtk rg --files src/cmds/system | head -2
src/cmds/system/summary.rs
src/cmds/system/ctest_cmd.rs

When stdin is a pipe, routing (stdin_is_readable()) takes the positional src/cmds/system to be the pattern and streams the output verbatim, tracked 0/0. When stdin is closed, the same command goes through the file-list path and gets compressed. The output is correct both times, but the saving depends on stdin instead of on the command.

Expected: --files takes paths, never a pattern, so it should route the same way whatever stdin is.

Seen on #4170's head, which adds the file-list fold shown above. The routing decision itself predates that PR.

Activity

  1. rtk-wshm-sync-bot commented on Sep 25, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 90%

    Summary

    rtk rg --files <path> routes based on stdin readability instead of the command itself, so the fold/compression in #4170 only applies when stdin is closed.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/cmds/rg.rs

    Suggested Actions

    1. Route --files by presence of the flag/positional path, not stdin_is_readable()
    2. Cross-check against feat(search): fold shared path prefix in file-list passthrough #4170's file-list fold to keep the compressed output path canonical
    3. Add a regression test invoking rtk rg --files <path> with stdin both open (piped) and closed

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  2. reopened this on Sep 25, 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions