Fix critical bug: incorrect return code check in exit logic

The issue was in line 378: if [[ $? -eq 0 ]]
- $? was checking the return code of 'local exit_reason=$(...)'
- This command always succeeds, so $? was always 0
- This caused Ralph to always exit immediately after loop #1

Fixed by:
- Calling should_exit_gracefully directly in the if condition
- Only calling it again to get exit reason if it returns 0 (exit needed)
- This properly checks the function's actual return code
This commit is contained in:
frankbria 2025-08-27 16:12:09 -07:00
parent a09957c068
commit 2a5452c18f

View file

@ -374,8 +374,8 @@ main() {
fi
# Check for graceful exit conditions
local exit_reason=$(should_exit_gracefully)
if [[ $? -eq 0 ]]; then
if should_exit_gracefully; then
local exit_reason=$(should_exit_gracefully)
log_status "SUCCESS" "🏁 Graceful exit triggered: $exit_reason"
update_status "$loop_count" "$(cat "$CALL_COUNT_FILE")" "graceful_exit" "completed" "$exit_reason"