2017-10-21 146 views
0

所以,你知道,你做你的标准getopts设置:有什么区别?和*在Bash?

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 

据我所知,?是比定义的其他标志和*是如果没有输入参数。但是,我不知道.... Bash中的问号和Asterisk之间

回答