我知道getopts,但每次我都必须进行解析和错误处理。
有没有人知道Bash是否存在一个“库”或一组函数来解析命令参数?
例如,Perl有很多这样的东西。
发布于 2012-10-31 02:09:50
也许getoptx是适合你的东西。尽管我发现getopts真的很好,顺便说一句:如果你使用用户输入,你应该总是做一些错误处理;-)
发布于 2013-07-09 23:26:02
bash-modules,“参数”模块。
示例:
#!/bin/bash
. import.sh log arguments
NAME="world"
parse_arguments "-n|--name)NAME;S" -- "$@" || {
error "Cannot parse command line."
exit 1
}
info "Hello, $NAME!"https://stackoverflow.com/questions/13145090
复制相似问题