From a5984eca8049d9cbcc74a21a3a381f5cdba26123 Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Tue, 8 Sep 2026 11:24:59 -0600 Subject: [PATCH] fix: exclude null bytes from fs_grep output on binaries --- assets/functions/tools/fs_grep.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) mode change 100644 => 100755 assets/functions/tools/fs_grep.sh diff --git a/assets/functions/tools/fs_grep.sh b/assets/functions/tools/fs_grep.sh old mode 100644 new mode 100755 index e7d92e9..c734508 --- a/assets/functions/tools/fs_grep.sh +++ b/assets/functions/tools/fs_grep.sh @@ -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"