CRITICAL: Guarantee menu loop NEVER exits to command line
Added explicit safeguards to ensure the menu loop ALWAYS returns to menu: 1. Check for empty menu_choice (handles EOF/Ctrl-D) - If empty, show error and continue (don't break loop) 2. Added infinite loop guarantee comment - The 'while true' should ONLY exit via explicit return 0 on option [0] 3. Added safety fallback at end of main() - If loop somehow breaks, return 0 gracefully REQUIREMENT: Pressing Enter at ANY prompt should return to menu, EXCEPT when user explicitly selects [0] to exit. This prevents the script from unexpectedly exiting to command line and ensures users always get back to the main menu to try again. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2950,9 +2950,17 @@ main() {
|
|||||||
local menu_choice=""
|
local menu_choice=""
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
# Infinite loop - only exits with explicit "return 0" on option [0]
|
||||||
show_step_menu
|
show_step_menu
|
||||||
read -r menu_choice
|
read -r menu_choice
|
||||||
|
|
||||||
|
# Ensure menu_choice is not empty (handle EOF/Ctrl-D)
|
||||||
|
if [ -z "$menu_choice" ]; then
|
||||||
|
print_error "Invalid option (empty input). Returning to menu."
|
||||||
|
press_enter
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
case $menu_choice in
|
case $menu_choice in
|
||||||
1)
|
1)
|
||||||
# Step 1: Detect live data directory
|
# Step 1: Detect live data directory
|
||||||
@@ -3138,6 +3146,10 @@ main() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# SAFETY: This line should never be reached (loop is infinite)
|
||||||
|
# But if it somehow is, return 0 to exit gracefully
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run main function
|
# Run main function
|
||||||
|
|||||||
Reference in New Issue
Block a user