Changeset 5758 for trunk/scripts

Show
Ignore:
Timestamp:
11/06/07 05:14:15 (13 months ago)
Author:
erijo
Message:

Update argument handling

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/scripts/tag-licq-release.sh

    r5660 r5758  
    1414 
    1515### END SETTINGS ### 
     16function usage() 
     17{ 
     18    echo "Usage: $0 -v version -r rev" 
     19    echo "  -h, --help  This message" 
     20    echo "  -v          Name the tag licq-<version> (e.g. 1.3.5-rc3)" 
     21    echo "  -r          Revision to tag (e.g. 5656)" 
     22} 
    1623 
    17 if [ $# -ne 2 ]; then 
    18   echo "Usage: $0 <version> <revision>" 
    19   echo "E.g. $0 1.3.5-rc3 5656" 
    20   exit 1 
     24args=$(getopt -n "$0" -o h,v:,r: -l help -- $*) 
     25if [ $? -ne 0 ]; then 
     26    echo "" 
     27    usage 
     28    exit 1 
    2129fi 
    2230 
    23 VERSION="licq-$1" 
    24 REV=$2 
     31set -- $args 
     32while [ $# -gt 0 ]; do 
     33    case $1 in 
     34    -h|--help) usage; exit 0 ;; 
     35    -v) VERSION="licq-$(eval echo $2)"; shift ;; 
     36    -r) REV=$(eval echo $2); shift ;; 
     37    --) ;; 
     38    *) echo "$0: unknown option '$1'"; exit 1 ;; 
     39    esac 
     40    shift 
     41done 
     42 
     43if [ -z "$VERSION" -o -z "$REV" ]; then 
     44    echo "$0: Missing argument" 
     45    echo "Try \`$0 --help' for more information" 
     46    exit 2 
     47fi 
    2548 
    2649TMPDIR=$(mktemp -d) || exit 1