Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2024-05-23 - Broken sed pipeline causing data loss
**Learning:** The command `sed 's// /g'` is invalid because of an empty regex and causes `sed` to fail. When used in a pipeline like `cat | sed | tr`, if `sed` fails, the downstream `tr` receives nothing, resulting in empty content for all files. Additionally, `cat file | ...` is an inefficient pattern (useless use of cat).
**Action:** Replace `cat file | sed ... | tr ...` with direct redirection `tr ... < file`. Always verify pipeline components individually to ensure they don't fail silently with `2>/dev/null`.
3 changes: 2 additions & 1 deletion codepack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,8 @@ 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 "")
# Optimization: Use input redirection instead of cat, and remove broken sed command
content=$(tr -cd '\11\12\15\40-\176' < "$file" 2>/dev/null || echo "")
fi

debug_log "Content length: ${#content}" >&2
Expand Down