Repository navigation
fix(discover): keep a trailing redirect when rewriting golangci-lint - #4340
Merged
Merged
Conversation
The golangci-lint rewrite rebuilt the command from its parsed global and
`run` segments and returned early, before the trailing redirect was put
back, so `golangci-lint run 2>&1` became `rtk golangci-lint run` and
output meant for a file or /dev/null reached the terminal instead.
Every rewrite of a supported command now builds only the command part
(`rewrite_command_part`), and the redirect split off before matching is
re-attached once, exactly as typed. A branch can no longer forget it, and
the original boundary is kept: `run ${PKG}2>/dev/null` stays one operand
followed by a redirect, with no separating space inserted.
Across every rule prefix combined with six trailing-redirect forms (1752
inputs), golangci-lint was the only rewrite that dropped the redirect;
with this change none does.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
📊 Automated PR Analysis
SummaryFixes a bug in the golangci-lint command rewrite where a trailing shell redirect (e.g. Review Checklist
Analyzed automatically by wshm · This is an automated analysis, not a human review. |
TaKO8Ki
self-requested a review
October 5, 2026 17:07
TaKO8Ki
approved these changes
Oct 5, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The golangci-lint rewrite drops a trailing redirect. The hook turns
into
rtk golangci-lint run ./...,rtk golangci-lint runandrtk golangci-lint run ./... | tail -5, so output the command sent to/dev/nullor merged into stdout reaches the terminal (and the agent's context) instead.The golangci-lint branch rebuilds the command from its parsed global and
runsegments and returned early, before the redirect split off for matching was put back. Every other rewrite path re-attaches it.Change
Every rewrite of a supported command now builds only the command part (
rewrite_command_part), and the trailing redirect is re-attached once, exactly as typed, for all of them. A special-case branch can no longer forget it, and the original boundary is kept:run ${PKG}2>/dev/nullstays one operand followed by a redirect, with no separating space inserted. The golangci parser also runs only for the golangci-lint rule instead of for every supported command.Verification
cargo fmt --all --check && cargo clippy --all-targets -- -D warnings && cargo test --all: 4071 passing, clippy clean.rtk rewriteinputs (all rule prefixes × argument shapes × redirect forms, with env prefixes, wrappers, pipelines,gh --jsonand PHP forms): only golangci-lint outputs differ, each by re-attaching the redirect verbatim. That includes./...2>&1, which develop turned into./...2.gh --json(still skipped) and PHP tools.🤖 Generated with Claude Code