summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormillert <>2004-12-07 16:14:35 +0000
committermillert <>2004-12-07 16:14:35 +0000
commit0a6f65508dd7e2acb05f027e4aaa28cd6a38cd03 (patch)
treee1e7ca287eca5a6f7f1fa7fe93f3863ebecb834d
parent66534e214cbc90c8e166a81ed98f302243b70cc6 (diff)
downloadopenbsd-0a6f65508dd7e2acb05f027e4aaa28cd6a38cd03.tar.gz
openbsd-0a6f65508dd7e2acb05f027e4aaa28cd6a38cd03.tar.bz2
openbsd-0a6f65508dd7e2acb05f027e4aaa28cd6a38cd03.zip
Document why not to set optind = 0. Inspired by and OK jfb@
-rw-r--r--src/lib/libc/stdlib/getopt.322
1 files changed, 20 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/getopt.3 b/src/lib/libc/stdlib/getopt.3
index d210852c6b..76546d2946 100644
--- a/src/lib/libc/stdlib/getopt.3
+++ b/src/lib/libc/stdlib/getopt.3
@@ -25,7 +25,7 @@
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE. 26.\" SUCH DAMAGE.
27.\" 27.\"
28.\" $OpenBSD: getopt.3,v 1.28 2003/09/22 23:47:26 millert Exp $ 28.\" $OpenBSD: getopt.3,v 1.29 2004/12/07 16:14:35 millert Exp $
29.\" 29.\"
30.Dd December 17, 2002 30.Dd December 17, 2002
31.Dt GETOPT 3 31.Dt GETOPT 3
@@ -95,9 +95,13 @@ and
95are both initialized to 1. 95are both initialized to 1.
96The 96The
97.Va optind 97.Va optind
98variable may be set to another value before a set of calls to 98variable may be set to another value larger than 0 before a set of calls to
99.Fn getopt 99.Fn getopt
100in order to skip over more or less argv entries. 100in order to skip over more or less argv entries.
101An
102.Va optind
103value of 0 is reserved for compatibility with GNU
104.Fn getopt .
101.Pp 105.Pp
102In order to use 106In order to use
103.Fn getopt 107.Fn getopt
@@ -230,6 +234,20 @@ variable was added to make it possible to call the
230.Fn getopt 234.Fn getopt
231function multiple times. 235function multiple times.
232.It Li o 236.It Li o
237If the
238.Va optind
239variable is set to 0,
240.Fn getopt
241will behave as if the
242.Va optreset
243variable has been set.
244This is for compatibility with
245.Tn GNU
246.Fn getopt .
247New code should use
248.Va optreset
249instead.
250.It Li o
233If the first character of 251If the first character of
234.Fa optstring 252.Fa optstring
235is a plus sign 253is a plus sign