~ubuntu-branches/ubuntu/warty/bash/warty

« back to all changes in this revision

Viewing changes to tests/getopts2.sub

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2002-04-08 20:51:41 UTC
  • Revision ID: james.westby@ubuntu.com-20020408205141-qovkhu3a90201hf2
Tags: upstream-2.05a
ImportĀ upstreamĀ versionĀ 2.05a

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
aflag=
 
2
bflag=
 
3
 
 
4
while getopts ab:c:de name "$@"
 
5
do
 
6
        case $name in
 
7
        a)      aflag=1 ;;
 
8
        b)      bflag=1
 
9
                bval=$OPTARG;;
 
10
        c)      cflag=1
 
11
                cval=$OPTARG ;;
 
12
        d)      dflag=1 ;;
 
13
        e)      eflag=1;;
 
14
        ?)      echo Usage: $0 [-a] [-b value] [-c value] -[de] args
 
15
                exit 2;;
 
16
        esac
 
17
 
 
18
done
 
19
 
 
20
[ ! -z "$aflag" ] && echo -a specified
 
21
[ ! -z "$bflag" ] && echo -b $bval specified
 
22
[ ! -z "$cflag" ] && echo -c $cval specified
 
23
[ ! -z "$dflag" ] && echo -d specified
 
24
[ ! -z "$eflag" ] && { echo -n - ; echo e specified; }
 
25
 
 
26
exit 0