Skip to content

Fix: #259 Windows grep backslash handling in _grep#339

Open
wasiqnauman wants to merge 1 commit into
mpfaffenberger:mainfrom
wasiqnauman:fix/windows-grep-259
Open

Fix: #259 Windows grep backslash handling in _grep#339
wasiqnauman wants to merge 1 commit into
mpfaffenberger:mainfrom
wasiqnauman:fix/windows-grep-259

Conversation

@wasiqnauman
Copy link
Copy Markdown
Contributor

Summary

This fixes a Windows bug in code_puppy.tools.file_operations._grep where search strings containing backslashes were corrupted before being passed to ripgrep.

The root cause was POSIX shlex.split(search_string), which treats \ as an escape character. On Windows that broke common searches like \bhello\b, \d+, foo.bar, and path-like input such as C:\Users\me.

Changes

use Windows-safe argument splitting for _grep
preserve backslashes in regex and path-like input
surface ripgrep errors instead of silently returning zero matches
add regression tests for Windows backslash handling and ripgrep error propagation
Notes
grep is still regex-based by default. A raw search like C:\Users\me now returns the real ripgrep regex error instead of looking like “no matches”. For literal path searches, use -F "C:\Users\me".

Passed:

pytest tests/tools/test_file_operations_coverage.py -q
pytest tests/tools/test_file_operations_coverage.py -q -k grep

Manual Windows smoke test:

\bhello_world\b matched
\d+ matched
-F "C:\Users\me" matched literal Windows paths

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.

1 participant