FIX: Critical startup flow issues - terminal crashes, inefficiency, inconsistency
CRITICAL FIXES: - TERMINAL CRASH: Changed 'exit 1' to 'return 1' in library sourcing (lines 21-25) Cause: When launcher.sh sourced from run.sh, 'exit' terminated the parent shell Impact: Terminal no longer crashes when libraries fail to load - CLEANUP FILE PATH: Simplified cleanup file creation to use consistent path Old: Created random temp file with mktemp (never checked by run.sh) New: Direct creation of /tmp/.cleanup_requested (checked by run.sh) Impact: Cleanup now works correctly on exit HIGH PRIORITY: - DATABASE QUERY OPTIMIZATION: Replaced 4 separate grep -c calls with single awk pass Old: 4 separate grep calls on same file (lines 666-669) New: Single awk pass with field counting (line 671) Impact: ~75% faster startup detection summary display MEDIUM PRIORITY: - CONSISTENT ERROR HANDLING: Standardized all read commands to use explicit failure checks Pattern: if ! read ... </dev/tty 2>/dev/null; then ... fi Applied to: startup detection prompt (line 681), main menu (line 705), cleanup prompt (line 720) Impact: Clearer error handling throughout launcher - DIRECTORY INITIALIZATION: Moved init_directories out of main loop Old: Called on every main() invocation New: Called once at startup with error handling Impact: Fewer redundant directory creation attempts - RUN.SH ERROR HANDLING: Added error handling for launcher.sh sourcing Added: Check for successful launcher.sh load with helpful error message Impact: Better failure diagnostics if launcher fails to load VERIFICATION: - Tested startup flow: Launcher initializes without crashes - Verified menu displays correctly - Confirmed cleanup file path consistency - All error handling patterns standardized
This commit is contained in:
@@ -30,7 +30,10 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
fi
|
||||
|
||||
# Run the launcher (source in current shell, don't execute in subshell)
|
||||
source "$SCRIPT_DIR/launcher.sh"
|
||||
source "$SCRIPT_DIR/launcher.sh" || {
|
||||
echo "ERROR: Failed to load launcher.sh"
|
||||
return 1
|
||||
}
|
||||
|
||||
# Check if cleanup is requested
|
||||
if [ -f /tmp/.cleanup_requested ]; then
|
||||
|
||||
Reference in New Issue
Block a user