diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2004-12-07 16:14:36 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2004-12-07 16:14:36 +0000 |
commit | 4327e193d476bd5cb9bad5ba8fb83b476dbafeb9 (patch) | |
tree | 3c53111ee933d6ff81656fea56392bc6a1dbd3b1 /lib | |
parent | 7621c38c0b0535d90a4b02abc7eeb35532e5edd5 (diff) |
Document why not to set optind = 0. Inspired by and OK jfb@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/stdlib/getopt.3 | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/libc/stdlib/getopt.3 b/lib/libc/stdlib/getopt.3 index d210852c6bd..76546d29464 100644 --- a/lib/libc/stdlib/getopt.3 +++ b/lib/libc/stdlib/getopt.3 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: getopt.3,v 1.28 2003/09/22 23:47:26 millert Exp $ +.\" $OpenBSD: getopt.3,v 1.29 2004/12/07 16:14:35 millert Exp $ .\" .Dd December 17, 2002 .Dt GETOPT 3 @@ -95,9 +95,13 @@ and are both initialized to 1. The .Va optind -variable may be set to another value before a set of calls to +variable may be set to another value larger than 0 before a set of calls to .Fn getopt in order to skip over more or less argv entries. +An +.Va optind +value of 0 is reserved for compatibility with GNU +.Fn getopt . .Pp In order to use .Fn getopt @@ -230,6 +234,20 @@ variable was added to make it possible to call the .Fn getopt function multiple times. .It Li o +If the +.Va optind +variable is set to 0, +.Fn getopt +will behave as if the +.Va optreset +variable has been set. +This is for compatibility with +.Tn GNU +.Fn getopt . +New code should use +.Va optreset +instead. +.It Li o If the first character of .Fa optstring is a plus sign |