summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstsp <>2020-01-13 18:05:10 +0000
committerstsp <>2020-01-13 18:05:10 +0000
commitc5507b93bae487b5b6ad4c1758fa9aafd207caf2 (patch)
treed8278a63c9fe6aee106014b918650908704cfe27
parentc4644b1171df29d076fb20433aeea3287786712f (diff)
downloadopenbsd-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.320
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
98processes long options if the abbreviation is unique. 98processes long options if the abbreviation is unique.
99An exact match is always preferred for a defined long option. 99An exact match is always preferred for a defined long option.
100.Pp 100.Pp
101By default,
102.Fn getopt_long
103permutes
104.Ar argv
105such that all option arguments are evaluated before any non-options arguments.
106If the first character of
107.Fa optstring
108is a plus sign
109.Pq Ql +
110or if the environment variable
111.Ev POSIXLY_CORRECT
112is set, then
113.Ar argv
114is processed in order and option processing stops as soon as the first
115non-option argument is encountered.
116.Pp
101The 117The
102.Fn getopt_long 118.Fn getopt_long
103call requires an array to be initialized describing the long 119call requires an array to be initialized describing the long