uninstall: accept yes with CR/spaces/case, read from tty

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Бобырев Андрей
2026-11-03 20:44:32 +03:00
parent d030344b00
commit 51ec84db6c

View File

@@ -21,8 +21,10 @@ echo " watchdog, бинарники, $PHOBOS_DIR, $PANEL_DIR"
echo "==================================================" echo "=================================================="
if [ "${PURGE:-0}" != "1" ]; then if [ "${PURGE:-0}" != "1" ]; then
printf "Точно удалить ВСЁ? [yes/NO]: " printf "Точно удалить ВСЁ? [yes/NO]: "
read ans read -r ans </dev/tty 2>/dev/null || read -r ans
[ "$ans" = "yes" ] || { echo "Отменено."; exit 0; } # tolerate CR from Windows/phone terminals, spaces, case, "да"
ans=$(printf '%s' "$ans" | tr -d '\r[:space:]' | tr '[:upper:]' '[:lower:]')
case "$ans" in yes|y|да|д) ;; *) echo "Отменено (нужно ввести yes)."; exit 0 ;; esac
fi fi
IFACE=$(ip route get 8.8.8.8 2>/dev/null | awk '{for(i=1;i<NF;i++) if($i=="dev") print $(i+1)}' | head -1) IFACE=$(ip route get 8.8.8.8 2>/dev/null | awk '{for(i=1;i<NF;i++) if($i=="dev") print $(i+1)}' | head -1)