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