mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 17:55:08 +00:00
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).
This commit is contained in:
@@ -950,12 +950,22 @@ main() {
|
|||||||
|
|
||||||
rm -f "$apps_file"
|
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
|
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
|
drain_pending_input
|
||||||
|
|
||||||
if [[ -z "$key" ]]; then
|
if [[ "$read_ok" == "true" && -z "$key" ]]; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
show_cursor
|
show_cursor
|
||||||
|
|||||||
Reference in New Issue
Block a user