Skip to content

Windows + Git Bash: quoted braces/globs are re-expanded, and head -N doesn't return the first N lines #4256

Closed as duplicate

Description

@Hermew

Thanks for rtk, the savings are real. Two things on Windows (Git Bash as the agent's shell)
made the output wrong rather than just shorter, so I had to exclude those commands:

  1. grep/find: when rtk.exe spawns Git Bash's grep/find, already-quoted braces and globs get
    expanded again (MSYS globbing of the child command line).

    • rtk grep -E '.{0,20}foo' file -> grep receives ".0foo.20"-style fragments, 0 results
    • rtk find . -not -path './x/*' -> "paths must precede expression"
      Setting MSYS=noglob fixes these two, but it's not a usable workaround: it breaks the command
      line of other Windows programs launched from bash. Reproduced on 0.49.0 and 0.50.0
      (eb11789 doesn't cover this case).
  2. head -N file is rewritten to rtk read --max-lines N, which returns a summary of the
    start and end of the file instead of the first N lines. An agent asking for the first
    lines gets different content without noticing.

Current workaround: exclude_commands = ["head", "tail", "grep", "find"].
Happy to test a fix.

Activity

  1. added
    bug
    help wanted
    on Sep 26, 2026
  2. rtk-wshm-sync-bot commented on Sep 26, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 88%

    Summary

    Windows/Git Bash: MSYS re-expands already-quoted grep/find args, and the head→rtk read --max-lines rewrite returns a head/tail summary instead of the first N lines.

    Suggested Actions

    1. Cross-reference head/cat/tail rewrites corrupt files when output is redirected, and rtk read --max-lines N returns ~N/2 lines #4202 (rtk read --max-lines N returns ~N/2 lines) — likely same underlying head/tail rewrite defect
    2. Cross-reference Windows (Git Bash): the hook rewrites grep over a large glob into rtk.exe, which fails with "Argument list too long" and the command never runs #4210 (Windows Git Bash grep/glob 'Argument list too long') for shared MSYS quoting root cause
    3. Fix head -N rewrite to return the literal first N lines instead of a summary view
    4. Investigate quoting/escaping used when rtk.exe spawns Git Bash grep/find to prevent MSYS re-globbing

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

  3. KuSh commented on Oct 3, 2026

    @KuSh
    Collaborator

    Closing as a duplicate of #4102, which tracks the MSYS/Cygwin re-globbing of quoted braces and */? arguments with a full measurement on a real Git Bash setup and the planned fix. The head -N part is already fixed since v0.50.0: head -20 file now rewrites to rtk read file --head-lines 20 and returns exactly the first 20 lines. Please follow up on #4102, and reopen here if head -N still misbehaves on v0.50.0 or later.

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

    area:clibughelp wantedplatform:windowspriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions