]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/getopts7.sub
Bash-4.3 patch 7
[thirdparty/bash.git] / tests / getopts7.sub
CommitLineData
726f6388
JA
1aflag=
2bflag=
3
d166f048 4while getopts :ab: opt-var "$@"
726f6388
JA
5do
6 case $name in
7 a) aflag=1 ;;
8 b) bflag=1
9 bval=$OPTARG;;
d166f048
JA
10 :) echo $0: error: option \`$OPTARG\' requires an argument
11 echo Usage: $0 [-a] [-b value] args
12 exit 2;;
13 ?) echo $0: error: illegal option character \`$OPTARG\'
14 echo Usage: $0 [-a] [-b value] args
726f6388
JA
15 exit 2;;
16 esac
17
18done
19
20if [ ! -z "$aflag" ] ; then echo -a specified ; fi
21if [ ! -z "$bflag" ] ; then echo -b $bval specified ; fi
22
23if [ "$OPTIND" -gt 1 ]
24then
25 shift $(( $OPTIND - 1 ))
26fi
27
28echo remaining args: "$*"
29
30exit 0