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

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

bash 3.1

File size: 425 bytes
Line 
1aflag=
2bflag=
3
4while getopts :ac name "$@"
5do
6 case $name in
7 a) aflag=1 ;;
8 c) cflag=1 ;;
9 ?) exit 2;;
10 esac
11
12 # this came in in a bug report -- it's really a usage error
13 # but it shouldn't cause the shell to crash
14 shift
15done
16
17if [ ! -z "$aflag" ] ; then echo -a specified ; fi
18if [ ! -z "$cflag" ] ; then echo -c specified ; fi
19
20if [ "$OPTIND" -gt 1 ]
21then
22 shift $(( $OPTIND - 1 ))
23fi
24
25echo remaining args: "$*"
26
27exit 0
Note: See TracBrowser for help on using the repository browser.