From 7a6da7b4193b0f88a6b0f2e9028ff9c26960428b Mon Sep 17 00:00:00 2001 From: tw93 Date: Thu, 26 Feb 2026 19:42:47 +0800 Subject: [PATCH] fix(uninstall): auto-exit return-to-list prompt after configurable timeout Replace blocking read with a timed read (default 3 s) so the prompt exits automatically instead of waiting forever. Timeout is configurable via MOLE_UNINSTALL_RETURN_PROMPT_TIMEOUT_SEC. Use a read_ok flag to distinguish timeout (exit) from Enter (return to list). --- bin/uninstall.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/uninstall.sh b/bin/uninstall.sh index 5c2a436..9d8960d 100755 --- a/bin/uninstall.sh +++ b/bin/uninstall.sh @@ -950,12 +950,22 @@ main() { rm -f "$apps_file" - echo -e "${GRAY}Press Enter to return to application list, any other key to exit...${NC}" + local prompt_timeout="${MOLE_UNINSTALL_RETURN_PROMPT_TIMEOUT_SEC:-3}" + if [[ ! "$prompt_timeout" =~ ^[0-9]+$ ]] || [[ "$prompt_timeout" -lt 1 ]]; then + prompt_timeout=3 + fi + + echo -e "${GRAY}Press Enter to return to the app list, press any other key or wait ${prompt_timeout}s to exit.${NC}" local key - IFS= read -r -s -n1 key || key="" + local read_ok=false + if IFS= read -r -s -n1 -t "$prompt_timeout" key; then + read_ok=true + else + key="" + fi drain_pending_input - if [[ -z "$key" ]]; then + if [[ "$read_ok" == "true" && -z "$key" ]]; then : else show_cursor