Skip to content

fix: rtk ls summary line inflates pipe count #482

Closed

Description

@FlorianBruniaux

Problem

rtk ls <dir> | wc -l returns a count inflated by 2 (blank line + summary line) because the 📊 summary is always written to stdout.

rtk ls src/ | wc -l   # returns N+2 (wrong)
ls src/ | wc -l        # returns N (correct)

This breaks any script that pipes rtk ls to count files or process entries.

Unix Convention

Metadata/summary goes to stderr or is suppressed when stdout is not a TTY. RTK already uses this pattern in gain.rs via std::io::IsTerminal.

ls itself does this — no summary when piped.

Proposed Fix

Suppress the 📊 summary line when stdout is piped (not a TTY). Show it only in interactive mode.

Changes to src/ls.rs

  • Add use std::io::IsTerminal;
  • Split compact_ls() return value into (entries: String, summary: String) tuple
  • In run(): always print entries, only print summary when stdout().is_terminal()
  • Track only what is actually sent to stdout for rtk gain accuracy

Verification

# Pipe mode — should NOT show summary
rtk ls src/ | wc -l

# TTY mode — should show summary
rtk ls src/

Activity

  1. added
    bug
    P3-nice-to-have
    on Mar 12, 2026
  2. added
    effort-small
    filter-quality
    good first issue
    on Mar 20, 2026
  3. pszymkowiak commented on Mar 20, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟢 Priority low
    🎯 Confidence 92%

    Summary

    rtk ls summary line written to stdout inflates pipe counts; should be suppressed when stdout is not a TTY. PR #503 already in progress.

    💡 This looks like a simple fix that could be auto-resolved. Use /wshm fix to attempt it.

    📁 Relevant files
    • src/ls.rs

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

  4. added 2 commits that reference this issue on May 14, 2026
    a275b3d
    d43bab4
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

    P3-nice-to-havebugeffort-smallfilter-qualitygood first issuepriority:low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions