Subject: Re: getopts in functions
From: Chet Ramey <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Wed, 18 Oct 2000 10:39:59 -0400

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

--
Want to unsubscribe from this list?
Send a message to [email-masked]