Skip to content

fix(hook): use POSIX character classes for portable grep matching#98

Merged
pszymkowiak merged 1 commit intortk-ai:masterfrom
mhcoen:fix/posix-regex-portability
Feb 13, 2026
Merged

fix(hook): use POSIX character classes for portable grep matching#98
pszymkowiak merged 1 commit intortk-ai:masterfrom
mhcoen:fix/posix-regex-portability

Conversation

@mhcoen
Copy link
Contributor

@mhcoen mhcoen commented Feb 13, 2026

Summary

  • Replace \s with [[:space:]] in all 41 grep -E patterns in rtk-rewrite.sh
  • \s is a PCRE extension not guaranteed by POSIX ERE, causing intermittent match failures on macOS depending on grep version and locale settings
  • This fixes commands like pytest, cargo test, git status etc. silently passing through without rewrite on affected systems

Test plan

  • 47 test cases covering all rewrite rules (git, cargo, docker, kubectl, gh, cat, ls, pytest, ruff, pip, go, vitest, pnpm, etc.)
  • Verified no-match cases still correctly pass through
  • Verified rtk-prefixed commands still skip rewrite
  • Tested in isolation on the original hook structure (no other changes)

🤖 Generated with Claude Code

…ibility

Replace \s with [[:space:]] in all grep -E patterns. The \s shorthand
is a PCRE extension not guaranteed by POSIX ERE, causing intermittent
match failures on macOS depending on grep version and locale settings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Collaborator

@pszymkowiak pszymkowiak left a comment

Choose a reason for hiding this comment

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

good.

@pszymkowiak pszymkowiak merged commit 4aafc83 into rtk-ai:master Feb 13, 2026
2 checks passed
FlorianBruniaux added a commit to FlorianBruniaux/rtk that referenced this pull request Feb 14, 2026
Resolved conflicts:
- Version bumped to 0.15.4 (Cargo.toml, Cargo.lock, .release-please-manifest.json)
- CHANGELOG.md: Added upstream releases (0.15.4, 0.15.3, 0.15.2)
- Hooks: Adopted POSIX character classes ([[:space:]]) from upstream
- src/parser/mod.rs: Added multibyte UTF-8 tests from upstream
- src/ruff_cmd.rs: Kept functions public for lint/format dispatcher feature

Upstream changes integrated:
- rtk-ai#120: git status fix for non-repo folders
- rtk-ai#93: UTF-8 panic prevention on multibyte chars
- rtk-ai#98: POSIX grep compatibility in hooks
- rtk-ai#95, rtk-ai#92: CI reliability and hook coverage improvements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ahundt pushed a commit to ahundt/rtk that referenced this pull request Feb 23, 2026
…ibility (rtk-ai#98)

Replace \s with [[:space:]] in all grep -E patterns. The \s shorthand
is a PCRE extension not guaranteed by POSIX ERE, causing intermittent
match failures on macOS depending on grep version and locale settings.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants