diff options
author | jaredy <> | 2005-07-26 04:17:44 +0000 |
---|---|---|
committer | jaredy <> | 2005-07-26 04:17:44 +0000 |
commit | 182eb10d8cb1661b4873a254245ae02caafeb8fe (patch) | |
tree | 009b82dfd81f29a352bd08885b1043fa712dfc0e /src | |
parent | 724bc3c0b0563d7753d33d7075ac6f4c83cb9c65 (diff) | |
download | openbsd-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.3 | 230 |
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 | |||
78 | structure passed to it for options that take arguments. | 78 | structure passed to it for options that take arguments. |
79 | Additionally, the long option's argument may be specified as a single | 79 | Additionally, the long option's argument may be specified as a single |
80 | argument with an equal sign, e.g. | 80 | argument with an equal sign, e.g. |
81 | .Bd -literal | 81 | .Bd -literal -offset indent |
82 | myprogram --myoption=somevalue | 82 | $ myprogram --myoption=somevalue |
83 | .Ed | 83 | .Ed |
84 | .Pp | 84 | .Pp |
85 | When a long option is processed the call to | 85 | When a long option is processed, the call to |
86 | .Fn getopt_long | 86 | .Fn getopt_long |
87 | will return 0. | 87 | will return 0. |
88 | For this reason, long option processing without | 88 | For this reason, long option processing without |
@@ -98,7 +98,7 @@ The | |||
98 | call requires a structure to be initialized describing the long | 98 | call requires a structure to be initialized describing the long |
99 | options. | 99 | options. |
100 | The structure is: | 100 | The structure is: |
101 | .Bd -literal | 101 | .Bd -literal -offset indent |
102 | struct option { | 102 | struct 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. | |||
114 | The | 114 | The |
115 | .Fa has_arg | 115 | .Fa has_arg |
116 | field should be one of: | 116 | field 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 |
119 | no argument to the option is expect. | 119 | .It Dv no_argument |
120 | .It Li required_argument | 120 | no argument to the option is expected. |
121 | .It Dv required_argument | ||
121 | an argument to the option is required. | 122 | an argument to the option is required. |
122 | .It Li optional_argument | 123 | .It Dv optional_argument |
123 | an argument to the option may be presented. | 124 | an 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 |
237 | This section describes differences to the GNU implementation | 238 | This section describes differences to the GNU implementation |
238 | found in glibc-2.1.3: | 239 | found in glibc-2.1.3: |
239 | .Bl -tag -width "xxx" | 240 | .Bl -bullet |
240 | .It Li o | 241 | .It |
241 | handling of - as first char of option string in presence of | 242 | handling of |
242 | environment variable POSIXLY_CORRECT: | 243 | .Ql - |
244 | as the first character of the option string in the presence of the | ||
245 | environment variable | ||
246 | .Ev POSIXLY_CORRECT : | ||
243 | .Bl -tag -width "OpenBSD" | 247 | .Bl -tag -width "OpenBSD" |
244 | .It Li GNU | 248 | .It GNU |
245 | ignores POSIXLY_CORRECT and returns non-options as | 249 | ignores |
246 | arguments to option '\e1'. | 250 | .Ev POSIXLY_CORRECT |
247 | .It Li OpenBSD | 251 | and returns non-options as arguments to option |
248 | honors POSIXLY_CORRECT and stops at the first non-option. | 252 | .Ql \e1 . |
253 | .It OpenBSD | ||
254 | honors | ||
255 | .Ev POSIXLY_CORRECT | ||
256 | and stops at the first non-option. | ||
249 | .El | 257 | .El |
250 | .It Li o | 258 | .It |
251 | handling of - within the option string (not the first character): | 259 | handling of |
260 | .Ql - | ||
261 | within the option string (not the first character): | ||
252 | .Bl -tag -width "OpenBSD" | 262 | .Bl -tag -width "OpenBSD" |
253 | .It Li GNU | 263 | .It GNU |
254 | treats a | 264 | treats a |
255 | .Ql - | 265 | .Ql - |
256 | on the command line as a non-argument. | 266 | on the command line as a non-argument. |
257 | .It Li OpenBSD | 267 | .It OpenBSD |
258 | a | 268 | a |
259 | .Ql - | 269 | .Ql - |
260 | within the option string matches a | 270 | within the option string matches a |
@@ -268,85 +278,157 @@ that use | |||
268 | as an option flag. | 278 | as an option flag. |
269 | This practice is wrong, and should not be used in any current development. | 279 | This practice is wrong, and should not be used in any current development. |
270 | .El | 280 | .El |
271 | .It Li o | 281 | .It |
272 | handling of :: in options string in presence of POSIXLY_CORRECT: | 282 | handling of |
283 | .Ql :: | ||
284 | in 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 |
275 | GNU and OpenBSD ignore POSIXLY_CORRECT here and take :: to | 288 | GNU and |
276 | mean the preceding option takes an optional argument. | 289 | .Ox |
290 | ignore | ||
291 | .Ev POSIXLY_CORRECT | ||
292 | here and take | ||
293 | .Ql :: | ||
294 | to mean the preceding option takes an optional argument. | ||
277 | .El | 295 | .El |
278 | .It Li o | 296 | .It |
279 | return value in case of missing argument if first character | 297 | return value in case of missing argument if first character |
280 | (after + or -) in option string is not ':': | 298 | (after |
299 | .Ql + | ||
300 | or | ||
301 | .Ql - ) | ||
302 | in the option string is not | ||
303 | .Ql \&: : | ||
281 | .Bl -tag -width "OpenBSD" | 304 | .Bl -tag -width "OpenBSD" |
282 | .It Li GNU | 305 | .It GNU |
283 | returns '?' | 306 | returns |
307 | .Ql \&? | ||
284 | .It OpenBSD | 308 | .It OpenBSD |
285 | returns ':' (since OpenBSD's getopt does). | 309 | returns |
310 | .Ql \&: | ||
311 | (since | ||
312 | .Ox Ns 's | ||
313 | .Xr getopt 3 | ||
314 | does). | ||
286 | .El | 315 | .El |
287 | .It Li o | 316 | .It |
288 | handling of --a in getopt: | 317 | handling of |
318 | .Ql --a | ||
319 | in | ||
320 | .Xr getopt 3 : | ||
289 | .Bl -tag -width "OpenBSD" | 321 | .Bl -tag -width "OpenBSD" |
290 | .It Li GNU | 322 | .It GNU |
291 | parses this as option '-', option 'a'. | 323 | parses this as option |
292 | .It Li OpenBSD | 324 | .Ql - , |
293 | parses this as '--', and returns \-1 (ignoring the a). | 325 | option |
294 | (Because the original getopt does.) | 326 | .Ql a . |
327 | .It OpenBSD | ||
328 | parses this as | ||
329 | .Ql -- , | ||
330 | and returns \-1 (ignoring the | ||
331 | .Ql a ) | ||
332 | (because the original | ||
333 | .Fn getopt | ||
334 | did.) | ||
295 | .El | 335 | .El |
296 | .It Li o | 336 | .It |
297 | setting of optopt for long options with flag != | 337 | setting of |
298 | .Dv NULL : | 338 | .Va optopt |
339 | for 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 |
301 | sets optopt to val. | 344 | sets |
302 | .It Li OpenBSD | 345 | .Va optopt |
303 | sets optopt to 0 (since val would never be returned). | 346 | to |
347 | .Va val . | ||
348 | .It OpenBSD | ||
349 | sets | ||
350 | .Va optopt | ||
351 | to 0 (since | ||
352 | .Va val | ||
353 | would never be returned). | ||
304 | .El | 354 | .El |
305 | .It Li o | 355 | .It |
306 | handling of -W with W; in option string in getopt (not getopt_long): | 356 | handling of |
357 | .Ql -W | ||
358 | with | ||
359 | .Ql W; | ||
360 | in 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 |
309 | causes a segfault. | 366 | causes a segmentation fault. |
310 | .It Li OpenBSD | 367 | .It OpenBSD |
311 | no special handling is done; | 368 | no special handling is done; |
312 | .Dq W; | 369 | .Ql W; |
313 | is interpreted as two separate options, neither of which take an argument. | 370 | is interpreted as two separate options, neither of which take an argument. |
314 | .El | 371 | .El |
315 | .It Li o | 372 | .It |
316 | setting of optarg for long options without an argument that are | 373 | setting of |
317 | invoked via -W (W; in option string): | 374 | .Va optarg |
375 | for long options without an argument that are invoked via | ||
376 | .Ql -W | ||
377 | (with | ||
378 | .Ql W; | ||
379 | in the option string): | ||
318 | .Bl -tag -width "OpenBSD" | 380 | .Bl -tag -width "OpenBSD" |
319 | .It Li GNU | 381 | .It GNU |
320 | sets optarg to the option name (the argument of -W). | 382 | sets |
321 | .It Li OpenBSD | 383 | .Va optarg |
322 | sets optarg to | 384 | to the option name (the argument of |
385 | .Ql -W ) . | ||
386 | .It OpenBSD | ||
387 | sets | ||
388 | .Va optarg | ||
389 | to | ||
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 |
327 | handling of -W with an argument that is not (a prefix to) a known | 394 | handling of |
328 | long option (W; in option string): | 395 | .Ql -W |
396 | with an argument that is not (a prefix to) a known long option | ||
397 | (with | ||
398 | .Ql W; | ||
399 | in the option string): | ||
329 | .Bl -tag -width "OpenBSD" | 400 | .Bl -tag -width "OpenBSD" |
330 | .It Li GNU | 401 | .It GNU |
331 | returns -W with optarg set to the unknown option. | 402 | returns |
332 | .It Li OpenBSD | 403 | .Ql -W |
333 | treats this as an error (unknown option) and returns '?' with | 404 | with |
334 | optopt set to 0 and optarg set to | 405 | .Va optarg |
406 | set to the unknown option. | ||
407 | .It OpenBSD | ||
408 | treats this as an error (unknown option) and returns | ||
409 | .Ql \&? | ||
410 | with | ||
411 | .Va optopt | ||
412 | set to 0 and | ||
413 | .Va optarg | ||
414 | set 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 |
339 | The error messages are different. | 419 | The error messages are different. |
340 | .It Li o | 420 | .It |
341 | OpenBSD does not permute the argument vector at the same points in | 421 | .Ox |
422 | does not permute the argument vector at the same points in | ||
342 | the calling sequence as GNU does. | 423 | the calling sequence as GNU does. |
343 | The aspects normally used by the caller | 424 | The aspects normally used by the caller |
344 | (ordering after \-1 is returned, value of optind relative | 425 | (ordering after \-1 is returned, value of |
345 | to current positions) are the same, though. | 426 | .Va optind |
427 | relative 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 |
351 | If set, option processing stops when the first non-option is found and | 433 | If set, option processing stops when the first non-option is found and |
352 | a leading | 434 | a leading |