【发布时间】:2020-03-20 14:08:04
【问题描述】:
我在脚本中编写了一个函数,如果在函数内部的 case 语句中条件不匹配,我想调用该函数。我的脚本不是再次调用该函数,而是打印或回显我的函数名称。
#!/bin/bash
function askUser() {
printf " AUS for Australia \n BAN for Bangladesh \n NEP for Nepal \n IND for India \n ENG for England\n "
read -p " Guess one of the best cricket team according to the country code" read
echo $read
TEAM="ENG"
case $read in
"AUS" | "BAN" | "NEP" | "IND") echo "SORRY!! You Guess the wrong team :(\n" askUser
;;
"ENG") echo "England is the best cricket team and recently had won the ICC trophy. "
;;
*) echo "Please select from the above Teams::):)"
esac
}
askUser
【问题讨论】:
-
你需要在这个
...:(\n"之后添加;,在函数名之前。 -
感谢您的回复,这对我很有帮助
-
c.f. List Commands.
标签: bash