source: vendor/bash/3.1-p17/tests/getopts3.sub

Last change on this file was 3228, checked in by bird, 18 years ago

bash 3.1

File size: 480 bytes
Line 
1aflag=
2bflag=
3
4while getopts ab: name -a -b 1 -a -a -a -b 5 -b 3 -a one two three four five
5do
6 case $name in
7 a) aflag=1 ;;
8 b) bflag=1
9 bval=$OPTARG;;
10 ?) echo Usage: $0 [-a] [-b value] args
11 exit 2;;
12 esac
13
14done
15
16if [ ! -z "$aflag" ] ; then echo -a specified ; fi
17if [ ! -z "$bflag" ] ; then echo -b $bval specified ; fi
18
19set -- -a -b 1 -a -a -a -b 5 -b 3 -a one two three four five
20if [ "$OPTIND" -gt 1 ]
21then
22 shift $(( $OPTIND - 1 ))
23fi
24
25echo remaining args: "$*"
26
27exit 0
Note: See TracBrowser for help on using the repository browser.