This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

getopts in functions


Should getopts work correctly in functions? I find if I try that if I
get an error processing the options, then retry the function, it seems
to get confused.

Do I have to do something explicit to reset getopts?

My code looks like (... elides detail):

function jc()
{
  while getopts "d:c:h" OPT; do
    case $OPT in
      d )  ... ;;
      c )  ... ;;
      h )  echo $USAGE 
           return 1 ;;
      \? ) echo "Error, unrecognized option"
           echo $USAGE 
           return 1 ;;
    esac
  done

  ...
}

-- 
Best regards,
 Andy              mailto:andy.philpotts@calendarcentral.com



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]