From b25a30615bf67b21b2158653460a27f4dcf6dae7 Mon Sep 17 00:00:00 2001 From: Nicola Belluti Date: Mon, 13 Oct 2025 11:53:35 +0200 Subject: [PATCH] Clear the input buffer when asking for confirmation in the setup script --- home/.chezmoiscripts/run_before_archlinux.sh.tmpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/home/.chezmoiscripts/run_before_archlinux.sh.tmpl b/home/.chezmoiscripts/run_before_archlinux.sh.tmpl index 26d5b36..1f00ea1 100755 --- a/home/.chezmoiscripts/run_before_archlinux.sh.tmpl +++ b/home/.chezmoiscripts/run_before_archlinux.sh.tmpl @@ -24,8 +24,12 @@ trap 'echo -e "\n\033[1;31mError: Script \"$SCRIPT_PATH\" failed at line $LINENO # # +# Ask for confirmation before running the script while true; do read -p "Do you want to run the setup script? [Y/n]: " -n 1 -r REPLY + + # Clear the input buffer and add a newline + while read -t 0.001 TMP; do continue; done echo # Convert to lowercase and default to 'y' if empty