repo.or.cz
/
bash.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Patch-ID: bash32-029
[bash.git]
/
tests
/
getopts5.sub
blob
c6e388816e34ecf9c3df2a6567682911fb2dedb7
1
#!/local/bin/bash
2
#Time-stamp: <95/06/07 07:40:40 hrue@imf.unit.no>
3
4
getop
() {
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
26
OPTIND
=
27
OPTERR
=
0
28
29
echo
OPTERR
=
$OPTERR
30
while
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
43
done
44
45
echo
OPTIND
=
$OPTIND
46
47
getop
"$@"
-d -e
48
49
echo
OPTIND
=
$OPTIND
50
echo
OPTERR
=
$OPTERR