delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/10/18/10:44:40

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Wed, 18 Oct 2000 10:39:59 -0400
From: Chet Ramey <chet AT nike DOT ins DOT cwru DOT edu>
To: andy DOT philpotts AT calendarcentral DOT com
Subject: Re: getopts in functions
Cc: cygwin AT sourceware DOT cygnus DOT com
Reply-To: chet AT po DOT CWRU DOT Edu
Message-ID: <1001018143959.AA05597.SM@nike.ins.cwru.edu>
Read-Receipt-To: chet AT po DOT CWRU DOT Edu
MIME-Version: 1.0
X-In-Reply-To: Message from andy DOT philpotts AT calendarcentral DOT com of Tue, 17 Oct 2000 18:03:27 -0400 (id <122102925068 DOT 20001017180327 AT calendarcentral DOT com>)

> 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 AT po DOT CWRU DOT Edu    http://cnswww.cns.cwru.edu/~chet/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019