]>
Commit | Line | Data |
---|---|---|
726f6388 JA |
1 | aflag= |
2 | bflag= | |
3 | ||
d166f048 | 4 | while getopts ab: name -a -b 1 -a -a -a -b 5 -b 3 -a one two three four five |
726f6388 JA |
5 | do |
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 | ||
14 | done | |
15 | ||
16 | if [ ! -z "$aflag" ] ; then echo -a specified ; fi | |
17 | if [ ! -z "$bflag" ] ; then echo -b $bval specified ; fi | |
18 | ||
d166f048 | 19 | set -- -a -b 1 -a -a -a -b 5 -b 3 -a one two three four five |
726f6388 JA |
20 | if [ "$OPTIND" -gt 1 ] |
21 | then | |
22 | shift $(( $OPTIND - 1 )) | |
23 | fi | |
24 | ||
25 | echo remaining args: "$*" | |
26 | ||
27 | exit 0 |