]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/getopts5.sub
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / getopts5.sub
1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 #
14 #Time-stamp: <95/06/07 07:40:40 hrue@imf.unit.no>
15
16 getop () {
17
18 local OPTIND=1
19 local OPTERR=1
20
21 echo getop: OPTERR=$OPTERR
22 while getopts ab arg "$@"; do
23 case $arg in
24 a)
25 echo a here
26 ;;
27 b)
28 echo b here
29 ;;
30 :|?|*)
31 echo something else here
32 ;;
33 esac
34 done
35 echo getop: OPTIND=$OPTIND
36 }
37
38 OPTIND=
39 OPTERR=0
40
41 echo OPTERR=$OPTERR
42 while getopts ab arg; do
43 case $arg in
44 a)
45 echo a here
46 ;;
47 b)
48 echo b here
49 ;;
50 :|?|*)
51
52 echo something else here
53 ;;
54 esac
55 done
56
57 echo OPTIND=$OPTIND
58
59 getop "$@" -d -e
60
61 echo OPTIND=$OPTIND
62 echo OPTERR=$OPTERR