ksh - default value for getopts option's argument

Hello everyone,

I need help in understanding the default value for getopts option's argument in ksh. I've written a short test script:

#!/bin/ksh

usage(){
   printf "Usage: -v and -m are mandatory\n\n"
}

while getopts ":v#[version:=58]m:[mirror:=ftp.tst.de]" opt; do
    case $opt in
        v) version="$OPTARG";;
        m) mirror="$OPTARG";;
        [?]) usage
             exit 1 ;;
    esac
done


shift $(($OPTIND - 1))

printf "version: $version\n"
printf "mirror: $mirror\n"

I'm testing the default value for getopts option's argument with the last 2 lines of the script. I was under the impression hey would have a default value if I do not specify the "-v" and "-m" option. I'm a bit confused here since I did assign a default value to each option.

I'm using KSH93 on an OpenBSD 5.8, amd64 vm.

Hi.

There is a working demonstration at post 7 in thread Help on getopts in ksh -- see if that can help ... cheers, drl