source: trunk/essentials/app-shells/bash/tests/getopts5.sub

Last change on this file was 3228, checked in by bird, 18 years ago

bash 3.1

File size: 632 bytes
Line 
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
Note: See TracBrowser for help on using the repository browser.