diff --git a/modules/performance/hardware-health-check.sh b/modules/performance/hardware-health-check.sh index a615801..6f99d42 100755 --- a/modules/performance/hardware-health-check.sh +++ b/modules/performance/hardware-health-check.sh @@ -1835,15 +1835,29 @@ main() { press_enter # Severity-based exit codes for monitoring system integration - # exit 0 = healthy (INFO only) - # exit 1 = warnings detected - # exit 2 = critical issues detected - case "$overall" in - CRITICAL) exit 2 ;; - WARNING) exit 1 ;; - *) exit 0 ;; - esac + # Only use exit codes when script is run standalone (not sourced by launcher) + # When sourced, the return value is available via $? but won't exit the parent shell + if [ "${BASH_SOURCE[0]}" = "${0}" ]; then + # Script is being run directly, use exit codes + case "$overall" in + CRITICAL) exit 2 ;; + WARNING) exit 1 ;; + *) exit 0 ;; + esac + else + # Script is being sourced (called from launcher), use return codes + case "$overall" in + CRITICAL) return 2 ;; + WARNING) return 1 ;; + *) return 0 ;; + esac + fi } -# Run main function -main +# Run main function only if script is executed directly (not sourced) +if [ "${BASH_SOURCE[0]}" = "${0}" ]; then + main +else + # When sourced, call main but don't auto-run + main +fi