2012-10-30 28 views

回答

3

也许getoptx是适合你的东西。虽然我发现getopts真的很好,顺便说一句:如果你使用用户输入,你应该总是做一些错误处理;-)

+0

这是非常整齐,但我得到一个SEG。 Ubuntu 12.04 64位10秒后出现故障。所以我想我必须努力去做。 –

1

bash-modules,“arguments”模块。

例子:

#!/bin/bash 
. import.sh log arguments 

NAME="world" 

parse_arguments "-n|--name)NAME;S" -- "[email protected]" || { 
    error "Cannot parse command line." 
    exit 1 
} 

info "Hello, $NAME!"