summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjaredy <>2005-07-26 04:17:44 +0000
committerjaredy <>2005-07-26 04:17:44 +0000
commit182eb10d8cb1661b4873a254245ae02caafeb8fe (patch)
tree009b82dfd81f29a352bd08885b1043fa712dfc0e /src
parent724bc3c0b0563d7753d33d7075ac6f4c83cb9c65 (diff)
downloadopenbsd-182eb10d8cb1661b4873a254245ae02caafeb8fe.tar.gz
openbsd-182eb10d8cb1661b4873a254245ae02caafeb8fe.tar.bz2
openbsd-182eb10d8cb1661b4873a254245ae02caafeb8fe.zip
- typos, grammar, punctuation, layout tweaks
- use `$' for command prompts - clean up: use a bullet list instead of adding junk to denote list items ok jmc
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/stdlib/getopt_long.3230
1 files changed, 156 insertions, 74 deletions
diff --git a/src/lib/libc/stdlib/getopt_long.3 b/src/lib/libc/stdlib/getopt_long.3
index 978583ef96..7899499cf7 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.10 2004/01/06 23:44:28 fgsch Exp $ 1.\" $OpenBSD: getopt_long.3,v 1.11 2005/07/26 04:17:44 jaredy 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
@@ -78,11 +78,11 @@ in the
78structure passed to it for options that take arguments. 78structure passed to it for options that take arguments.
79Additionally, the long option's argument may be specified as a single 79Additionally, the long option's argument may be specified as a single
80argument with an equal sign, e.g. 80argument with an equal sign, e.g.
81.Bd -literal 81.Bd -literal -offset indent
82myprogram --myoption=somevalue 82$ myprogram --myoption=somevalue
83.Ed 83.Ed
84.Pp 84.Pp
85When a long option is processed the call to 85When a long option is processed, the call to
86.Fn getopt_long 86.Fn getopt_long
87will return 0. 87will return 0.
88For this reason, long option processing without 88For this reason, long option processing without
@@ -98,7 +98,7 @@ The
98call requires a structure to be initialized describing the long 98call requires a structure to be initialized describing the long
99options. 99options.
100The structure is: 100The structure is:
101.Bd -literal 101.Bd -literal -offset indent
102struct option { 102struct option {
103 char *name; 103 char *name;
104 int has_arg; 104 int has_arg;
@@ -114,12 +114,13 @@ field should contain the option name without the leading double dash.
114The 114The
115.Fa has_arg 115.Fa has_arg
116field should be one of: 116field should be one of:
117.Bl -tag -width "optional_argument" 117.Pp
118.It Li no_argument 118.Bl -tag -width "optional_argument" -compact -offset indent
119no argument to the option is expect. 119.It Dv no_argument
120.It Li required_argument 120no argument to the option is expected.
121.It Dv required_argument
121an argument to the option is required. 122an argument to the option is required.
122.It Li optional_argument 123.It Dv optional_argument
123an argument to the option may be presented. 124an argument to the option may be presented.
124.El 125.El
125.Pp 126.Pp
@@ -236,25 +237,34 @@ argv += optind;
236.Sh IMPLEMENTATION DIFFERENCES 237.Sh IMPLEMENTATION DIFFERENCES
237This section describes differences to the GNU implementation 238This section describes differences to the GNU implementation
238found in glibc-2.1.3: 239found in glibc-2.1.3:
239.Bl -tag -width "xxx" 240.Bl -bullet
240.It Li o 241.It
241handling of - as first char of option string in presence of 242handling of
242environment variable POSIXLY_CORRECT: 243.Ql -
244as the first character of the option string in the presence of the
245environment variable
246.Ev POSIXLY_CORRECT :
243.Bl -tag -width "OpenBSD" 247.Bl -tag -width "OpenBSD"
244.It Li GNU 248.It GNU
245ignores POSIXLY_CORRECT and returns non-options as 249ignores
246arguments to option '\e1'. 250.Ev POSIXLY_CORRECT
247.It Li OpenBSD 251and returns non-options as arguments to option
248honors POSIXLY_CORRECT and stops at the first non-option. 252.Ql \e1 .
253.It OpenBSD
254honors
255.Ev POSIXLY_CORRECT
256and stops at the first non-option.
249.El 257.El
250.It Li o 258.It
251handling of - within the option string (not the first character): 259handling of
260.Ql -
261within the option string (not the first character):
252.Bl -tag -width "OpenBSD" 262.Bl -tag -width "OpenBSD"
253.It Li GNU 263.It GNU
254treats a 264treats a
255.Ql - 265.Ql -
256on the command line as a non-argument. 266on the command line as a non-argument.
257.It Li OpenBSD 267.It OpenBSD
258a 268a
259.Ql - 269.Ql -
260within the option string matches a 270within the option string matches a
@@ -268,85 +278,157 @@ that use
268as an option flag. 278as an option flag.
269This practice is wrong, and should not be used in any current development. 279This practice is wrong, and should not be used in any current development.
270.El 280.El
271.It Li o 281.It
272handling of :: in options string in presence of POSIXLY_CORRECT: 282handling of
283.Ql ::
284in the option string in the presence of
285.Ev POSIXLY_CORRECT :
273.Bl -tag -width "OpenBSD" 286.Bl -tag -width "OpenBSD"
274.It Li Both 287.It Both
275GNU and OpenBSD ignore POSIXLY_CORRECT here and take :: to 288GNU and
276mean the preceding option takes an optional argument. 289.Ox
290ignore
291.Ev POSIXLY_CORRECT
292here and take
293.Ql ::
294to mean the preceding option takes an optional argument.
277.El 295.El
278.It Li o 296.It
279return value in case of missing argument if first character 297return value in case of missing argument if first character
280(after + or -) in option string is not ':': 298(after
299.Ql +
300or
301.Ql - )
302in the option string is not
303.Ql \&: :
281.Bl -tag -width "OpenBSD" 304.Bl -tag -width "OpenBSD"
282.It Li GNU 305.It GNU
283returns '?' 306returns
307.Ql \&?
284.It OpenBSD 308.It OpenBSD
285returns ':' (since OpenBSD's getopt does). 309returns
310.Ql \&:
311(since
312.Ox Ns 's
313.Xr getopt 3
314does).
286.El 315.El
287.It Li o 316.It
288handling of --a in getopt: 317handling of
318.Ql --a
319in
320.Xr getopt 3 :
289.Bl -tag -width "OpenBSD" 321.Bl -tag -width "OpenBSD"
290.It Li GNU 322.It GNU
291parses this as option '-', option 'a'. 323parses this as option
292.It Li OpenBSD 324.Ql - ,
293parses this as '--', and returns \-1 (ignoring the a). 325option
294(Because the original getopt does.) 326.Ql a .
327.It OpenBSD
328parses this as
329.Ql -- ,
330and returns \-1 (ignoring the
331.Ql a )
332(because the original
333.Fn getopt
334did.)
295.El 335.El
296.It Li o 336.It
297setting of optopt for long options with flag != 337setting of
298.Dv NULL : 338.Va optopt
339for long options with
340.Va flag
341.No non- Ns Dv NULL :
299.Bl -tag -width "OpenBSD" 342.Bl -tag -width "OpenBSD"
300.It Li GNU 343.It GNU
301sets optopt to val. 344sets
302.It Li OpenBSD 345.Va optopt
303sets optopt to 0 (since val would never be returned). 346to
347.Va val .
348.It OpenBSD
349sets
350.Va optopt
351to 0 (since
352.Va val
353would never be returned).
304.El 354.El
305.It Li o 355.It
306handling of -W with W; in option string in getopt (not getopt_long): 356handling of
357.Ql -W
358with
359.Ql W;
360in the option string in
361.Xr getopt 3
362(not
363.Fn getopt_long ) :
307.Bl -tag -width "OpenBSD" 364.Bl -tag -width "OpenBSD"
308.It Li GNU 365.It GNU
309causes a segfault. 366causes a segmentation fault.
310.It Li OpenBSD 367.It OpenBSD
311no special handling is done; 368no special handling is done;
312.Dq W; 369.Ql W;
313is interpreted as two separate options, neither of which take an argument. 370is interpreted as two separate options, neither of which take an argument.
314.El 371.El
315.It Li o 372.It
316setting of optarg for long options without an argument that are 373setting of
317invoked via -W (W; in option string): 374.Va optarg
375for long options without an argument that are invoked via
376.Ql -W
377(with
378.Ql W;
379in the option string):
318.Bl -tag -width "OpenBSD" 380.Bl -tag -width "OpenBSD"
319.It Li GNU 381.It GNU
320sets optarg to the option name (the argument of -W). 382sets
321.It Li OpenBSD 383.Va optarg
322sets optarg to 384to the option name (the argument of
385.Ql -W ) .
386.It OpenBSD
387sets
388.Va optarg
389to
323.Dv NULL 390.Dv NULL
324(the argument of the long option). 391(the argument of the long option).
325.El 392.El
326.It Li o 393.It
327handling of -W with an argument that is not (a prefix to) a known 394handling of
328long option (W; in option string): 395.Ql -W
396with an argument that is not (a prefix to) a known long option
397(with
398.Ql W;
399in the option string):
329.Bl -tag -width "OpenBSD" 400.Bl -tag -width "OpenBSD"
330.It Li GNU 401.It GNU
331returns -W with optarg set to the unknown option. 402returns
332.It Li OpenBSD 403.Ql -W
333treats this as an error (unknown option) and returns '?' with 404with
334optopt set to 0 and optarg set to 405.Va optarg
406set to the unknown option.
407.It OpenBSD
408treats this as an error (unknown option) and returns
409.Ql \&?
410with
411.Va optopt
412set to 0 and
413.Va optarg
414set to
335.Dv NULL 415.Dv NULL
336(as GNU's man page documents). 416(as GNU's man page documents).
337.El 417.El
338.It Li o 418.It
339The error messages are different. 419The error messages are different.
340.It Li o 420.It
341OpenBSD does not permute the argument vector at the same points in 421.Ox
422does not permute the argument vector at the same points in
342the calling sequence as GNU does. 423the calling sequence as GNU does.
343The aspects normally used by the caller 424The aspects normally used by the caller
344(ordering after \-1 is returned, value of optind relative 425(ordering after \-1 is returned, value of
345to current positions) are the same, though. 426.Va optind
427relative to current positions) are the same, though.
346(We do fewer variable swaps.) 428(We do fewer variable swaps.)
347.El 429.El
348.Sh ENVIRONMENT 430.Sh ENVIRONMENT
349.Bl -tag -width POSIXLY_CORRECT 431.Bl -tag -width Ev
350.It Ev POSIXLY_CORRECT 432.It Ev POSIXLY_CORRECT
351If set, option processing stops when the first non-option is found and 433If set, option processing stops when the first non-option is found and
352a leading 434a leading