Skip to content

Commit 62158f5

Browse files
committed
fix: preserve newline character in project structure conversion
Command substitution ($()) strips trailing newlines, causing the newline variable to be empty. This resulted in sed deleting all \\n sequences instead of converting them to actual newlines. Changed from: newline=$(printf '\n') # Strips newline To: printf -v newline '\n' # Preserves newline This fixes malformed project structure sections in generated agent context files where directories should appear on separate lines. Fixes issue where get_project_structure() output like "backend/\\nfrontend/\\ntests/" was not properly converted to multi-line format in agent files.
1 parent a998d13 commit 62158f5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

scripts/bash/update-agent-context.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ create_new_agent_file() {
347347
done
348348

349349
# Convert \n sequences to actual newlines
350-
newline=$(printf '\n')
350+
# Use printf -v to assign without command substitution (which strips trailing newlines)
351+
printf -v newline '\n'
351352
sed -i.bak2 "s/\\\\n/${newline}/g" "$temp_file"
352353

353354
# Clean up backup files

0 commit comments

Comments
 (0)