]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/getopts5.sub
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / getopts5.sub
CommitLineData
8868edaf
CR
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#
d166f048
JA
14#Time-stamp: <95/06/07 07:40:40 hrue@imf.unit.no>
15
16getop () {
17
d233b485 18 local OPTIND=1
d166f048
JA
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
38OPTIND=
39OPTERR=0
40
41echo OPTERR=$OPTERR
42while 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
55done
56
57echo OPTIND=$OPTIND
58
59getop "$@" -d -e
60
61echo OPTIND=$OPTIND
62echo OPTERR=$OPTERR