Objective
Fix 7 shellcheck warnings (SC2129) across 3 workflows by consolidating multiple redirect operations into grouped commands for better performance and code clarity.
Context
ShellCheck Rule SC2129: "Consider using { cmd1; cmd2; } >> file instead of individual redirects"
Why it matters:
- Performance: Each redirect opens/closes the file separately
- Efficiency: Grouped redirects open file once, write all content, close once
- Code quality: More readable and maintainable
Impact Level: Low - These are style/performance improvements, not breaking errors.
Affected Workflows
| Workflow |
Location |
Count |
| beads-worker.lock.yml |
Line 956 |
3 warnings |
| smoke-copilot-no-firewall.lock.yml |
Various |
3 warnings |
| daily-choice-test.lock.yml |
Line 981 |
1 warning |
Current Pattern (Inefficient)
# ❌ Multiple redirects - opens file 3 times
echo "line 1" >> output.txt
echo "line 2" >> output.txt
echo "line 3" >> output.txt
Each >> operation:
- Opens
output.txt
- Seeks to end
- Writes content
- Closes file
Improved Pattern (Efficient)
# ✅ Grouped redirect - opens file once
{
echo "line 1"
echo "line 2"
echo "line 3"
} >> output.txt
Single operation:
- Opens
output.txt once
- Writes all content
- Closes file once
Fix Examples
Example 1: Simple echo statements
Before:
echo "Status: success" >> report.txt
echo "Time: $(date)" >> report.txt
echo "Files processed: $count" >> report.txt
After:
{
echo "Status: success"
echo "Time: $(date)"
echo "Files processed: $count"
} >> report.txt
Example 2: Mixed commands
Before:
echo "=== Results ===" >> log.txt
cat results.json >> log.txt
echo "=== End ===" >> log.txt
After:
{
echo "=== Results ==="
cat results.json
echo "=== End ==="
} >> log.txt
Example 3: With variables
Before:
echo "STEP_OUTPUT=$output" >> $GITHUB_ENV
echo "STEP_STATUS=$status" >> $GITHUB_ENV
echo "STEP_TIME=$time" >> $GITHUB_ENV
After:
{
echo "STEP_OUTPUT=$output"
echo "STEP_STATUS=$status"
echo "STEP_TIME=$time"
} >> $GITHUB_ENV
Files to Modify
Markdown source files (fix these, then recompile):
-
.github/workflows/beads-worker.md
- Find the section around line 956 in compiled output
- Consolidate 3 redirect operations
-
.github/workflows/smoke-copilot-no-firewall.md
- Find sections with multiple redirects
- Consolidate 3 redirect operations
-
.github/workflows/daily-choice-test.md
- Find the section around line 981 in compiled output
- Consolidate redirect operation
Validation Steps
- Locate the shell script block in markdown source
- Identify consecutive lines with
>> same_file
- Wrap them in
{ ... } group with single redirect
- Recompile:
make recompile
- Run shellcheck:
shellcheck -x .github/workflows/{workflow}.lock.yml or via actionlint
- Verify SC2129 warnings are gone
Acceptance Criteria
Testing
# After fixes
make recompile
# Validate with actionlint (includes shellcheck)
actionlint .github/workflows/beads-worker.lock.yml
actionlint .github/workflows/smoke-copilot-no-firewall.lock.yml
actionlint .github/workflows/daily-choice-test.lock.yml
# Or use gh-aw compile
gh aw compile --actionlint .github/workflows/beads-worker.md
Performance Impact
For files with many redirects, the improvement can be measurable:
# Benchmark example (10 redirects)
time for i in {1..10}; do echo "line $i" >> test.txt; done
# Real: 0.012s
time { for i in {1..10}; do echo "line $i"; done } >> test.txt
# Real: 0.003s
# ~4x faster
Additional Improvements
While fixing SC2129, also look for:
- Unnecessary subshells
- Inefficient loops with redirects
- Multiple redirects to different files that could be grouped
References
AI generated by Plan Command for discussion #9119
Objective
Fix 7 shellcheck warnings (SC2129) across 3 workflows by consolidating multiple redirect operations into grouped commands for better performance and code clarity.
Context
ShellCheck Rule SC2129: "Consider using
{ cmd1; cmd2; } >> fileinstead of individual redirects"Why it matters:
Impact Level: Low - These are style/performance improvements, not breaking errors.
Affected Workflows
Current Pattern (Inefficient)
Each
>>operation:output.txtImproved Pattern (Efficient)
Single operation:
output.txtonceFix Examples
Example 1: Simple echo statements
Before:
After:
{ echo "Status: success" echo "Time: $(date)" echo "Files processed: $count" } >> report.txtExample 2: Mixed commands
Before:
After:
{ echo "=== Results ===" cat results.json echo "=== End ===" } >> log.txtExample 3: With variables
Before:
After:
{ echo "STEP_OUTPUT=$output" echo "STEP_STATUS=$status" echo "STEP_TIME=$time" } >> $GITHUB_ENVFiles to Modify
Markdown source files (fix these, then recompile):
.github/workflows/beads-worker.md.github/workflows/smoke-copilot-no-firewall.md.github/workflows/daily-choice-test.mdValidation Steps
>> same_file{ ... }group with single redirectmake recompileshellcheck -x .github/workflows/{workflow}.lock.ymlor via actionlintAcceptance Criteria
{ ... }syntaxTesting
Performance Impact
For files with many redirects, the improvement can be measurable:
Additional Improvements
While fixing SC2129, also look for:
References
specs/github-actions-security-best-practices.mdRelated to [plan] Fix static analysis findings from January 2026 scan #9122