]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/getopts5.sub
bash-5.0 distribution sources and documentation
[thirdparty/bash.git] / tests / getopts5.sub
CommitLineData
d166f048
JA
1#Time-stamp: <95/06/07 07:40:40 hrue@imf.unit.no>
2
3getop () {
4
d233b485 5 local OPTIND=1
d166f048
JA
6 local OPTERR=1
7
8 echo getop: OPTERR=$OPTERR
9 while getopts ab arg "$@"; do
10 case $arg in
11 a)
12 echo a here
13 ;;
14 b)
15 echo b here
16 ;;
17 :|?|*)
18 echo something else here
19 ;;
20 esac
21 done
22 echo getop: OPTIND=$OPTIND
23}
24
25OPTIND=
26OPTERR=0
27
28echo OPTERR=$OPTERR
29while getopts ab arg; do
30 case $arg in
31 a)
32 echo a here
33 ;;
34 b)
35 echo b here
36 ;;
37 :|?|*)
38
39 echo something else here
40 ;;
41 esac
42done
43
44echo OPTIND=$OPTIND
45
46getop "$@" -d -e
47
48echo OPTIND=$OPTIND
49echo OPTERR=$OPTERR