diff options
author | stsp <> | 2020-01-13 18:05:10 +0000 |
---|---|---|
committer | stsp <> | 2020-01-13 18:05:10 +0000 |
commit | c5507b93bae487b5b6ad4c1758fa9aafd207caf2 (patch) | |
tree | d8278a63c9fe6aee106014b918650908704cfe27 | |
parent | c4644b1171df29d076fb20433aeea3287786712f (diff) | |
download | openbsd-c5507b93bae487b5b6ad4c1758fa9aafd207caf2.tar.gz openbsd-c5507b93bae487b5b6ad4c1758fa9aafd207caf2.tar.bz2 openbsd-c5507b93bae487b5b6ad4c1758fa9aafd207caf2.zip |
Document how to make getopt_long(3) process arguments in order and stop
at the first non-option argument.
I had to read source code to figure it out.
-rw-r--r-- | src/lib/libc/stdlib/getopt_long.3 | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/getopt_long.3 b/src/lib/libc/stdlib/getopt_long.3 index 88e0dffb1b..706619203f 100644 --- a/src/lib/libc/stdlib/getopt_long.3 +++ b/src/lib/libc/stdlib/getopt_long.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: getopt_long.3,v 1.21 2016/01/04 19:43:13 tb Exp $ | 1 | .\" $OpenBSD: getopt_long.3,v 1.22 2020/01/13 18:05:10 stsp Exp $ |
2 | .\" $NetBSD: getopt_long.3,v 1.11 2002/10/02 10:54:19 wiz Exp $ | 2 | .\" $NetBSD: getopt_long.3,v 1.11 2002/10/02 10:54:19 wiz Exp $ |
3 | .\" | 3 | .\" |
4 | .\" Copyright (c) 1988, 1991, 1993 | 4 | .\" Copyright (c) 1988, 1991, 1993 |
@@ -30,7 +30,7 @@ | |||
30 | .\" | 30 | .\" |
31 | .\" @(#)getopt.3 8.5 (Berkeley) 4/27/95 | 31 | .\" @(#)getopt.3 8.5 (Berkeley) 4/27/95 |
32 | .\" | 32 | .\" |
33 | .Dd $Mdocdate: January 4 2016 $ | 33 | .Dd $Mdocdate: January 13 2020 $ |
34 | .Dt GETOPT_LONG 3 | 34 | .Dt GETOPT_LONG 3 |
35 | .Os | 35 | .Os |
36 | .Sh NAME | 36 | .Sh NAME |
@@ -98,6 +98,22 @@ Abbreviated long option names are accepted when | |||
98 | processes long options if the abbreviation is unique. | 98 | processes long options if the abbreviation is unique. |
99 | An exact match is always preferred for a defined long option. | 99 | An exact match is always preferred for a defined long option. |
100 | .Pp | 100 | .Pp |
101 | By default, | ||
102 | .Fn getopt_long | ||
103 | permutes | ||
104 | .Ar argv | ||
105 | such that all option arguments are evaluated before any non-options arguments. | ||
106 | If the first character of | ||
107 | .Fa optstring | ||
108 | is a plus sign | ||
109 | .Pq Ql + | ||
110 | or if the environment variable | ||
111 | .Ev POSIXLY_CORRECT | ||
112 | is set, then | ||
113 | .Ar argv | ||
114 | is processed in order and option processing stops as soon as the first | ||
115 | non-option argument is encountered. | ||
116 | .Pp | ||
101 | The | 117 | The |
102 | .Fn getopt_long | 118 | .Fn getopt_long |
103 | call requires an array to be initialized describing the long | 119 | call requires an array to be initialized describing the long |