diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 0000000..0ef691e --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2025-12-23 - Broken sed pipeline caused data loss +**Learning:** The command `sed 's// /g'` with an empty pattern is invalid and exits with code 1. When used in a pipe `cat | sed | tr` where stderr is redirected to `/dev/null`, it silently fails and breaks the pipe, resulting in empty output. +**Action:** Always verify regex patterns in `sed`. Use `tr` for simple character replacements. Avoid suppressing stderr blindly when debugging critical data pipelines. diff --git a/codepack.sh b/codepack.sh index 0d8ae2c..8c5ee28 100755 --- a/codepack.sh +++ b/codepack.sh @@ -851,7 +851,9 @@ extract_files_content() { # Read file content and clean invalid characters local content="" if [[ -r "$file" && -s "$file" ]]; then - content=$(cat "$file" 2>/dev/null | sed 's// /g' 2>/dev/null | tr -cd '\11\12\15\40-\176' 2>/dev/null || echo "") + # Optimized file reading: avoid cat and broken sed 's// /g' + # Use tr directly on input file to filter non-printable characters + content=$(tr -cd '\11\12\15\40-\176' < "$file" 2>/dev/null || echo "") fi debug_log "Content length: ${#content}" >&2