#!/bin/bash # $HeadURL$ $LastChangedRevision$ set -e PROGNAME=$(basename $0) # Load support functions . $(pcms-config PCMS_SHARE_PREFIX)/scripts/support.sh main() { # Defaults for options VERBOSELEVEL=2 OPT_PROGNAME=$PROGNAME # Process options while [ $# -ge 1 ]; do case $1 in -d) VERBOSELEVEL=$2; shift ;; --debug=*) VERBOSELEVEL=${1#*=} ;; -v|--verbose) VERBOSELEVEL=3 ;; --progname=*) OPT_PROGNAME=${1#*=} ;; --) shift; break ;; -*) error "main: $1: bad option" ;; *) break ;; esac shift done # Process arguments [ $# -ge 2 ] || usage FUNCTION=$1 shift [[ $FUNCTION =~ ^(info|internal|error|warning|debug)$ ]] || usage # Guts PROGNAME=$OPT_PROGNAME $FUNCTION "$@" } usage() { echo "Usage: $PROGNAME [ ] [ ] " >&2; exit 1; } main "$@"