From 53e8b12bcbb52fdf9c0787801e18c7f258e7b464 Mon Sep 17 00:00:00 2001 From: Miles Goodhew Date: Thu, 26 Jan 2023 01:33:34 +1100 Subject: [PATCH] Use printf and case around the read statements to make the prompts a bit friendlier --- edit-options.sh | 8 ++++---- install-driver.sh | 16 ++++++++-------- remove-driver.sh | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/edit-options.sh b/edit-options.sh index 83c7f7d..aa9af3a 100755 --- a/edit-options.sh +++ b/edit-options.sh @@ -52,11 +52,11 @@ echo ": ${SCRIPT_NAME} v${SCRIPT_VERSION}" ${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE} -echo "Do you want to apply the new options by rebooting now? [y/N] " +printf "Do you want to apply the new options by rebooting now? [y/N] " read -r REPLY echo # move to a new line -if [ "${REPLY}" = y ] || [ "${REPLY}" = Y ]; then - reboot -fi +case "$REPLY" in + [yY]*) reboot ;; +esac exit 0 diff --git a/install-driver.sh b/install-driver.sh index 77712d5..5c6e1a9 100755 --- a/install-driver.sh +++ b/install-driver.sh @@ -342,19 +342,19 @@ fi # if NoPrompt is not used, ask user some questions if [ $NO_PROMPT -ne 1 ]; then - echo "Do you want to edit the driver options file now? [y/N]" + printf "Do you want to edit the driver options file now? [y/N] " read -r REPLY echo - if [ "$REPLY" = y ] || [ "$REPLY" = Y ]; then - ${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE} - fi + case "$REPLY" in + [yY]*) ${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE} ;; + esac - echo "Do you want to reboot now? (recommended) [y/N]" + printf "Do you want to reboot now? (recommended) [y/N] " read -r REPLY echo - if [ "$REPLY" = y ] || [ "$REPLY" = Y ]; then - reboot - fi + case "$REPLY" in + [yY]*) reboot ;; + esac fi exit 0 diff --git a/remove-driver.sh b/remove-driver.sh index 9b00cf7..7131eda 100755 --- a/remove-driver.sh +++ b/remove-driver.sh @@ -129,12 +129,12 @@ echo "You may now delete the driver directory if desired." # if NoPrompt is not used, ask user some questions if [ $NO_PROMPT -ne 1 ]; then - echo "Do you want to reboot now? (recommended) [y/N]" + printf "Do you want to reboot now? (recommended) [y/N] " read -r REPLY echo - if [ "$REPLY" = y ] || [ "$REPLY" = Y ]; then - reboot - fi + case "$REPLY" in + [yY]*) reboot ;; + esac fi exit 0