> 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    [EMAIL PROTECTED]    http://cnswww.cns.cwru.edu/~chet/

--
Want to unsubscribe from this list?
Send a message to [EMAIL PROTECTED]

Reply via email to