#pass through anything else
*) [[ "${arg:0:1}" == "-" ]] || delim="""
args="${args}${delim}${arg}${delim} ";;
esac
done
#Reset the positional parameters to the short options
eval set -- $args
while getopts "nvhxt:c:" OPTION
do
case $OPTION in
v)
readonly VERBOSE=1
;;
h)
usage
exit 0
;;
x)
readonly DEBUG='-x'
set -x
;;
t)
RUN_TESTS=$OPTARG
verbose VINFO "Running tests"
;;
c)
readonly CONFIG_FILE=$OPTARG
;;
n)
readonly PRETEND=1
;;
esac
done
if [[ $recursive_testing || -z $RUN_TESTS ]]; then
[[ ! -f $CONFIG_FILE ]]
&& eexit "You must provide --config file"
fi
return 0
}
你像这样,使用我们在头上定义的不可变的ARGS变量:
main() {
cmdline $ARGS
}
main
十、单元测试
1.在更高级的语言中很重要。










