From 09cf0d1aac4bf08e76df849d34503ece4fbdc844 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Feb 25 2011 02:55:03 +0000 Subject: Update cli_printMessage.sh: - Don't use FLAG_ANSWER directly on verifications. Use an intermediate variable and assign the value of FLAG_ANSWER variable to the intermediate variable. This we each time a yes or no request line is called the value of answer is reset. Otherwise, if value is not reset, we may end up with positive answer on all yes or no requests and that is no what AsYesOrNoRequestLine option exists for. --- diff --git a/Scripts/Bash/centos-art/Functions/cli_printMessage.sh b/Scripts/Bash/centos-art/Functions/cli_printMessage.sh index 2637e4f..b2da4dd 100755 --- a/Scripts/Bash/centos-art/Functions/cli_printMessage.sh +++ b/Scripts/Bash/centos-art/Functions/cli_printMessage.sh @@ -121,13 +121,16 @@ function cli_printMessage { # Define negative answer. local N="`gettext "no"`" - if [[ $FLAG_ANSWER == 'false' ]];then + # Define default answer. + local ANSWER=${FLAG_ANSWER} + + if [[ $ANSWER == 'false' ]];then # Print the question. cli_printMessage "$MESSAGE [${Y}/${N}]: " 'AsNoTrailingNewLine' - # Wait for user's answer to be entered. - read FLAG_ANSWER + # Redefine default answer based on user's input. + read ANSWER fi @@ -135,7 +138,7 @@ function cli_printMessage { # script flow to continue. Otherwise, if something # different from possitive answer is passed, the # script terminates its execution immediatly. - if [[ ! ${FLAG_ANSWER} =~ "^${Y}" ]];then + if [[ ! ${ANSWER} =~ "^${Y}" ]];then exit fi ;;