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