Re: assign a string variable onto itself with concat ksh



At 2006-09-28 03:58PM, "theshowmecanuck" wrote:
I am trying to weed out mutually exclusive command line options by
[...]
Or is there an easier way to check for mutually exclusive options?

I'd write it like:

arg_o=""
arg_r=""
do_help=no

while getopts ":o:r:h" param; do
case "$param" in
h) do_help=yes ;; # delay help to allow for error processing
o) arg_o="$OPTARG" ;;
r) arg_r="$OPTARG" ;;
:) echo "missing argument for '-$OPTARG'"; exit 1 ;;
?) echo "unknown option: '-$OPTARG'"; exit 1 ;;
esac
done

if [ -n "$arg_r" -a -n "$arg_o" ]; then
echo "can't specify both -o and -r"
exit 1
fi

if [ $do_help = yes ]; then
usage
exit
fi


--
Glenn Jackman
Ulterior Designer
.



Relevant Pages