Merge pull request #161 from labolado/fix/grep-count-exit-code-bug
Fix grep -c exit code causing arithmetic syntax error
This commit is contained in:
commit
316e6e41c6
1 changed files with 6 additions and 3 deletions
|
|
@ -495,8 +495,10 @@ should_exit_gracefully() {
|
||||||
# Fix #144: Only match valid markdown checkboxes, not date entries like [2026-01-29]
|
# Fix #144: Only match valid markdown checkboxes, not date entries like [2026-01-29]
|
||||||
# Valid patterns: "- [ ]" (uncompleted) and "- [x]" or "- [X]" (completed)
|
# Valid patterns: "- [ ]" (uncompleted) and "- [x]" or "- [X]" (completed)
|
||||||
if [[ -f "$RALPH_DIR/fix_plan.md" ]]; then
|
if [[ -f "$RALPH_DIR/fix_plan.md" ]]; then
|
||||||
local uncompleted_items=$(grep -cE "^[[:space:]]*- \[ \]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || echo "0")
|
local uncompleted_items=$(grep -cE "^[[:space:]]*- \[ \]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || true)
|
||||||
local completed_items=$(grep -cE "^[[:space:]]*- \[[xX]\]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || echo "0")
|
[[ -z "$uncompleted_items" ]] && uncompleted_items=0
|
||||||
|
local completed_items=$(grep -cE "^[[:space:]]*- \[[xX]\]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || true)
|
||||||
|
[[ -z "$completed_items" ]] && completed_items=0
|
||||||
local total_items=$((uncompleted_items + completed_items))
|
local total_items=$((uncompleted_items + completed_items))
|
||||||
|
|
||||||
if [[ $total_items -gt 0 ]] && [[ $completed_items -eq $total_items ]]; then
|
if [[ $total_items -gt 0 ]] && [[ $completed_items -eq $total_items ]]; then
|
||||||
|
|
@ -602,7 +604,8 @@ build_loop_context() {
|
||||||
# Extract incomplete tasks from fix_plan.md
|
# Extract incomplete tasks from fix_plan.md
|
||||||
# Bug #3 Fix: Support indented markdown checkboxes with [[:space:]]* pattern
|
# Bug #3 Fix: Support indented markdown checkboxes with [[:space:]]* pattern
|
||||||
if [[ -f "$RALPH_DIR/fix_plan.md" ]]; then
|
if [[ -f "$RALPH_DIR/fix_plan.md" ]]; then
|
||||||
local incomplete_tasks=$(grep -cE "^[[:space:]]*- \[ \]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || echo "0")
|
local incomplete_tasks=$(grep -cE "^[[:space:]]*- \[ \]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || true)
|
||||||
|
[[ -z "$incomplete_tasks" ]] && incomplete_tasks=0
|
||||||
context+="Remaining tasks: ${incomplete_tasks}. "
|
context+="Remaining tasks: ${incomplete_tasks}. "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue