-
Notifications
You must be signed in to change notification settings - Fork 9
fix(redirect): >> append to file duplicates content in compound commands #1119
Copy link
Copy link
Closed
Description
Summary
When a compound command block uses >> (append) to build a file incrementally, content gets duplicated. This manifests as duplicate footer sections in generated HTML files.
Reproduction
echo "line1" > /tmp/test.html
echo "line2" >> /tmp/test.html
# So far, so good
# But in bashblog's create_includes pattern:
if [[ -f footer_file ]]; then
cp footer_file .footer.html
else
{
echo "<div>footer line 1</div>"
echo "<div>footer line 2</div>"
} >> ".footer.html" # This appends when .footer.html already exists
fiThe result is .footer.html containing the footer content twice.
Context
Discovered while running bashblog via bashkit CLI. The create_includes() function first creates .header.html with >, then appends .footer.html with >>. After a rebuild cycle, the generated HTML files contain duplicate <div id="footer"> sections.
Observed in rebuilt post files:
<div id="footer">CC by-nc-nd ... bashblog</div>
<div id="footer">CC by-nc-nd ... bashblog</div> <!-- duplicate -->Expected behavior
>> should append to the file exactly once per write operation. The file should not accumulate duplicate content across rebuild cycles when the same script creates and then appends to the same file.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels