fix: exclude null bytes from fs_grep output on binaries

This commit is contained in:
Dark-Alex-17 committed 2026-09-08 11:24:59 -06:00
1 parent 4651658b34
commit a5984eca80
1 file changed
+5 -1
+5 -1
View File
@@ -59,7 +59,11 @@ main() {
# (they only matter when recursing into a directory tree).
local results
results=$(grep "${grep_args[@]}" -E "$search_pattern" "$search_path" 2>/dev/null | head -n "$MAX_RESULTS") || true
# tr strips NUL bytes from matches in real binary files (text mode searches
# them), which would otherwise trigger bash's "ignored null byte in input"
# warning in the command substitution. -I can't be used instead: it overrides
# --binary-files=text and re-skips the misdetected UTF-8 files noted above.
results=$(grep "${grep_args[@]}" -E "$search_pattern" "$search_path" 2>/dev/null | tr -d '\0' | head -n "$MAX_RESULTS") || true
if [[ -z "$results" ]]; then
echo "No matches found for: $search_pattern" >> "$LLM_OUTPUT"