ask question function added

This commit is contained in:
victor 2020-02-14 09:03:44 +03:30
parent 3d86a0b6d2
commit 08c18871c1
1 changed files with 23 additions and 3 deletions

View File

@ -1,10 +1,10 @@
#!/usr/bin/env bash
main (){
main(){
check_arg $1
echo "shah"
ask_question "you are uninstalling photoshop cc v19 are you sure?" "N"
}
error (){
error(){
echo -e "\033[1;31merror:\e[0m $@"
exit 1
}
@ -15,4 +15,24 @@ check_arg(){
fi
}
#parameters [Message] [default flag [Y/N]]
function ask_question(){
result=""
if [ "$2" == "Y" ];then
read -r -p "$1 [Y/n] " response
if [[ "$response" =~ $(locale noexpr) ]];then
result="no"
else
result="yes"
fi
elif [ "$2" == "N" ];then
read -r -p "$1 [N/y] " response
if [[ "$response" =~ $(locale yesexpr) ]];then
result="yes"
else
result="no"
fi
fi
}
main $# $@