Skip to content

fix: strip trailing stderr redirects before rewrite matching (#530)#797

Merged
pszymkowiak merged 1 commit intodevelopfrom
fix/strip-stderr-redirects
Mar 24, 2026
Merged

fix: strip trailing stderr redirects before rewrite matching (#530)#797
pszymkowiak merged 1 commit intodevelopfrom
fix/strip-stderr-redirects

Conversation

@pszymkowiak
Copy link
Collaborator

Closes #530

Problem

rtk rewrite "git status 2>&1" returned nothing because 2>&1 was part of the string passed to pattern matching.

Fix

Strip trailing redirects (2>&1, 2>/dev/null, etc.) before matching, re-append after rewrite.

git status 2>&1       → rtk git status 2>&1
cargo test 2>/dev/null → rtk cargo test 2>/dev/null
git log 2> /dev/null  → rtk git log 2> /dev/null

Test plan

  • 1111 tests passing
  • Tested with rtk rewrite on all redirect patterns
  • Existing rewrites unaffected

@pszymkowiak pszymkowiak added bug Something isn't working effort-small Quelques heures, 1 fichier labels Mar 24, 2026
@pszymkowiak
Copy link
Collaborator Author

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟡 Risk medium

Summary

Fixes a bug where trailing stderr/stdout redirects (e.g., 2>&1, 2>/dev/null) were included in the pattern matching string during command rewriting, causing rewrites to fail silently. The fix strips trailing redirects before matching and re-appends them after rewriting.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #530


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

@pszymkowiak pszymkowiak force-pushed the fix/strip-stderr-redirects branch 4 times, most recently from 22b062b to 084f18e Compare March 24, 2026 11:33
Commands like `git status 2>&1` or `cargo test 2>/dev/null` were not
rewritten because the redirect suffix prevented pattern matching.

Now strips redirects (2>&1, 2>/dev/null, etc.) before matching,
then re-appends them to the rewritten command.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
@pszymkowiak pszymkowiak force-pushed the fix/strip-stderr-redirects branch from 084f18e to 36a6f48 Compare March 24, 2026 11:35
@pszymkowiak pszymkowiak requested a review from aeppling March 24, 2026 14:00
Copy link
Collaborator

@FlorianBruniaux FlorianBruniaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@pszymkowiak pszymkowiak merged commit edd9c02 into develop Mar 24, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working effort-small Quelques heures, 1 fichier

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants