Parsing 如何检查ash脚本中的额外参数?
我有一个ash脚本,我需要检查用户是否输入了任何愚蠢的内容。正确的使用方法是:Parsing 如何检查ash脚本中的额外参数?,parsing,getopts,ash,Parsing,Getopts,Ash,我有一个ash脚本,我需要检查用户是否输入了任何愚蠢的内容。正确的使用方法是: script <read | monitor> -s <system | event> [-f filter] [-n number] 为了解析正确的参数,我使用 while getopts "s:f:n:" Option do case $Option in s)logname=${OPTARG};; f)filterspec=${OPTARG};; n)num
script <read | monitor> -s <system | event> [-f filter] [-n number]
为了解析正确的参数,我使用
while getopts "s:f:n:" Option
do
case $Option in
s)logname=${OPTARG};;
f)filterspec=${OPTARG};;
n)numlines=${OPTARG};;
*)exit $E_OPTERROR;; # DEFAULT
esac
OPRIND=${OPTIND}
done
如何检测是否有任何剩余的未分析参数?退出while循环后,可以使用此选项: 它在bash中像贝壳一样工作,让我们知道它是否也在ash中工作
while getopts "s:f:n:" Option
do
case $Option in
s)logname=${OPTARG};;
f)filterspec=${OPTARG};;
n)numlines=${OPTARG};;
*)exit $E_OPTERROR;; # DEFAULT
esac
OPRIND=${OPTIND}
done
shift $(($OPTIND - 1))
echo "Remaining arguments: $@"