[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getopts

From: Chet Ramey
Subject: Re: getopts
Date: Sun, 2 Feb 2003 15:06:15 -0500

> Machine Type: i386-suse-linux
> Bash Version: 2.05
> Patch Level: 0
> Release Status: release
> Description:
>         [Detailed description of the problem, suggestion, or complaint.]
> I am trying to write a shell function in bash.  I want the function to 
> be as useful as possible so I use "getopts" to process options to the 
> function.  Below in the Repeat-By Section, I have included a sample 
> script with an example of a function I tried to write.  And I also 
> included the output when I run the script so hopefully it is clear what 
> is going wrong.

You need to reset OPTIND before each call to getopts.  There is a bug in
the current version of bash that causes `let OPTIND=1' to not perform the
special handling required to reset the internal state.  `OPTIND=1' works.


``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )

Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]