Ask a shell question-Linux general technology-Linux programming and kernel information. The following is a detailed description. Continue_promptYN ()
{
_ STR = $1
_ DEFAULT = $2
If [$ #-lt 1]; then
Echo "continue_prompt: I need a string to display"
Return 1
Fi
While:
Do
Echo-n "$ _ STR [Y... N] [$ _ DEFAULT]:"
Read _ ANS
:$ {_ ANS: =$ _ DEFAULT}
If ["$ ANS" = ""]; then
Case $ _ ANS in
Y) return 0
;;
N) return 1 ;;
Esac
Fi
Case $ _ ANS in
Y | y | Yes | YES)
Return 0
;;
N | N | No | NO)
Return 1
;;
*) Echo "answer either Y or N, default is $ _ DEFAULT"
;;
Esac
Echo $ _ ANS
Done
}
What is the purpose of this function? I changed a few codes and it seems that the result is not affected. Can I omit some statements?
You cannot understand this sentence: $ {_ ANS: =$ _ DEFAULT}. Thank you!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.