所以你知道,你做了标准getopts
设置:
while getopts :a:bc option
do
case "${option}"
in
a)
# do a manditory thing!
;;
b)
# do a optional thing!
;;
c)
# for real, you usually would set variables using getopts
;;
?) # unexpected flag(?)
echo "FATAL: Unexpected flag ${OPTARG}"
exit 2
;;
*) # litterally nothing entered(?)
show_help
exit 1
;;
esac
done
据我所知,?
用于除定义之外的标志,如果没有输入参数,则*
用于。但是,我不确定......
答案 0 :(得分:1)
Bash中问号与Asterisk的区别:
?
:匹配任何单个字符
*
:匹配任意数量的任何字符,包括无