壳牌小把戏

所有的Varnish程序都可以使用单个参数调用 --optstring 请求他们的 getopt() 规范,它简化了包装器脚本:

optstring=$(varnishfoo --optstring)

while getopts "$optstring" opt
do
    case $opt in
    n)
        # handle $OPTARG
        ;;
    # handle other options
    *)
        # ignore unneeded options
        ;;
    esac
done

varnishfoo "$@"

# do something with the options