From e52958db9371f009b04954bd54dcbb5672d388fb Mon Sep 17 00:00:00 2001 From: marcone <48169102+marcone@users.noreply.github.com> Date: Sun, 27 Nov 2022 12:45:03 -0800 Subject: [PATCH] armbian-firstlogin: make Y/n questions consistent (#4489) Make the two Y/n questions that firstlogin asks behave consistently with each other, and more in line with user expectation: - Reject anything that is not Y, y, N, n or . Previously the "Connect via wireless? [Y/n]" question would interpret Y, y and as "yes", and everything else as "no", whereas the "Set user language based on your location? [Y/n]" question would loop until the user selected Y, y, N or n. - Make pressing enter equivalent to the default "Y", since that is the capitalized option. - Echo back what the user typed. --- .../bsp/common/usr/lib/armbian/armbian-firstlogin | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/bsp/common/usr/lib/armbian/armbian-firstlogin b/packages/bsp/common/usr/lib/armbian/armbian-firstlogin index ff1ab38e17..750afe40b0 100644 --- a/packages/bsp/common/usr/lib/armbian/armbian-firstlogin +++ b/packages/bsp/common/usr/lib/armbian/armbian-firstlogin @@ -119,9 +119,13 @@ set_timezone_and_locales() if [[ -n "$WIFI_DEVICE" ]]; then echo -e "Internet connection was \x1B[91mnot detected\x1B[0m." echo "" - read -n1 -s -r -p "Connect via wireless? [Y/n] " response - echo "" - if [[ "${response}" =~ ^(Y|y|"")$ ]]; then + unset response + while [[ ! "${response}" =~ ^(Y|y|N|n)$ ]]; do + read -n1 -s -r -p "Connect via wireless? [Y/n] " response + response=${response:-Y} + echo "$response" + done + if [[ "${response}" =~ ^(Y|y)$ ]]; then nmtui-connect fi echo "" @@ -148,7 +152,8 @@ set_timezone_and_locales() unset response while [[ ! "${response}" =~ ^(Y|y|N|n)$ ]]; do read -n1 -s -r -p "Set user language based on your location? [Y/n] " response - echo "" + response=${response:-Y} + echo "$response" done # change it only if we have a match and if we agree if [[ "${response}" =~ ^(N|n)$ ]]; then