diff options
author | millert <> | 2004-12-07 16:14:35 +0000 |
---|---|---|
committer | millert <> | 2004-12-07 16:14:35 +0000 |
commit | 0a6f65508dd7e2acb05f027e4aaa28cd6a38cd03 (patch) | |
tree | e1e7ca287eca5a6f7f1fa7fe93f3863ebecb834d | |
parent | 66534e214cbc90c8e166a81ed98f302243b70cc6 (diff) | |
download | openbsd-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.3 | 22 |
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 | |||
95 | are both initialized to 1. | 95 | are both initialized to 1. |
96 | The | 96 | The |
97 | .Va optind | 97 | .Va optind |
98 | variable may be set to another value before a set of calls to | 98 | variable may be set to another value larger than 0 before a set of calls to |
99 | .Fn getopt | 99 | .Fn getopt |
100 | in order to skip over more or less argv entries. | 100 | in order to skip over more or less argv entries. |
101 | An | ||
102 | .Va optind | ||
103 | value of 0 is reserved for compatibility with GNU | ||
104 | .Fn getopt . | ||
101 | .Pp | 105 | .Pp |
102 | In order to use | 106 | In 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 |
231 | function multiple times. | 235 | function multiple times. |
232 | .It Li o | 236 | .It Li o |
237 | If the | ||
238 | .Va optind | ||
239 | variable is set to 0, | ||
240 | .Fn getopt | ||
241 | will behave as if the | ||
242 | .Va optreset | ||
243 | variable has been set. | ||
244 | This is for compatibility with | ||
245 | .Tn GNU | ||
246 | .Fn getopt . | ||
247 | New code should use | ||
248 | .Va optreset | ||
249 | instead. | ||
250 | .It Li o | ||
233 | If the first character of | 251 | If the first character of |
234 | .Fa optstring | 252 | .Fa optstring |
235 | is a plus sign | 253 | is a plus sign |