This is the mail archive of the
cygwin@sources.redhat.com
mailing list for the Cygwin project.
Re: getopts in functions
- To: andy dot philpotts at calendarcentral dot com
- Subject: Re: getopts in functions
- From: Chet Ramey <chet at nike dot ins dot cwru dot edu>
- Date: Wed, 18 Oct 2000 10:39:59 -0400
- Cc: cygwin at sourceware dot cygnus dot com
- Read-Receipt-To: chet@po.CWRU.Edu
- Reply-To: chet at po dot CWRU dot Edu
> 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?
Yes. The bash manual page says
The shell does not reset OPTIND automatically; it must be
manually reset between multiple calls to getopts within the
same shell invocation if a new set of parameters is to be used.
`Resetting OPTIND' means to assign it the value 1.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)
Chet Ramey, CWRU chet@po.CWRU.Edu http://cnswww.cns.cwru.edu/~chet/
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com