using getopt for both short and long options

Hi ,

I am using getopt for both short and long options as below

SHORTOPTS="a:c"
LONGOPTS="alpha:,charlie"
OPTS=$(getopt -o $SHORTOPTS --longoptions $LONGOPTS -n "$progname" -- "$@")
eval set -- "$OPTS"

while [ $# -gt 0 ]; do
case $1 in
-a|--alpha)
echo "-a or --alpha specified with "$2
shift 2
;;
-c|--charlie)
echo "-c or --charlie specified"
shift
;;
esac
done

if i run the above program like this ./sample1 --al hi or ./sample1 --cha

its taking --al as --alpha and --cha as --charlie

How to avoid this.It should take the option only if i give the entire option as --charlie and not --ch.Please help me.

Regards,
Padmini

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

Proceed here:

http://www.unix.com/shell-programming-scripting/116707-using-getopt-both-short-long-options.html\#post302343290

The UNIX and Linux Forums.