]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - misc-utils/getopt.1
blkid: (man) add note about udev encoding
[thirdparty/util-linux.git] / misc-utils / getopt.1
index 6558e12bfd3dfa7756e0adbbc640d59436245722..47e032b7ac37deb190d9d73e0d6610597223ede7 100644 (file)
@@ -1,19 +1,28 @@
-.TH GETOPT "1" "June 2012" "util-linux" "User Commands"
+.TH GETOPT "1" "December 2014" "util-linux" "User Commands"
 .SH NAME
 getopt \- parse command options (enhanced)
 .SH SYNOPSIS
-getopt optstring parameters
+.B getopt
+.I optstring parameters
 .br
-getopt [options] [\-\-] optstring parameters
+.B getopt
+[options]
+.RB [ \-\- ]
+.I optstring parameters
 .br
-getopt [options] \-o|\-\-options optstring [options] [\-\-]
+.B getopt
+[options]
+.BR \-o | \-\-options
+.I optstring
+[options]
+.RB [ \-\- ]
 .I parameters
 .SH DESCRIPTION
 .B getopt
 is used to break up
 .RI ( parse )
 options in command lines for easy parsing by shell procedures, and to
-check for legal options.  It uses the
+check for valid options.  It uses the
 .SM GNU
 .BR getopt (3)
 routines to do this.
@@ -21,10 +30,11 @@ routines to do this.
 The parameters
 .B getopt
 is called with can be divided into two parts: options which modify
-the way getopt will parse
-.RI ( options
-and
-.BR \-o | \-\-options
+the way
+.B getopt
+will do the parsing
+.RI "(the " options
+and the
 .I optstring
 in the
 .BR SYNOPSIS ),
@@ -44,10 +54,11 @@ part is used as the short options string.
 .PP
 If the environment variable
 .B GETOPT_COMPATIBLE
-is set, or if its first parameter is not an option (does not start
-with a
+is set, or if the first
+.I parameter
+is not an option (does not start with a
 .RB ' \- ',
-this is the first format in the
+the first format in the
 .BR SYNOPSIS ),
 .B getopt
 will generate output that is compatible with that of other versions of
@@ -59,7 +70,7 @@ for more information).
 .PP
 Traditional implementations of
 .BR getopt (1)
-are unable to cope with whitespace and other (shell\-specific)
+are unable to cope with whitespace and other (shell-specific)
 special characters in arguments and non\-option parameters.  To solve
 this problem, this implementation can generate quoted output which
 must once again be interpreted by the shell (usually by using the
@@ -82,8 +93,7 @@ Allow long options to start with a single
 .RB ' \- '.
 .TP
 .BR \-h , " \-\-help"
-Output a small usage guide and exit successfully.  No other output is
-generated.
+Display help text and exit.  No other output is generated.
 .TP
 .BR \-l , " \-\-longoptions \fIlongopts\fP"
 The long (multi\-character) options to be recognized.  More than one
@@ -129,11 +139,12 @@ Disable error reporting by getopt(3).
 Do not generate normal output.  Errors are still reported by
 .BR getopt (3),
 unless you also use
-.IR \-q .
+.BR \-q .
 .TP
 .BR \-s , " \-\-shell \fIshell\fP"
-Set quoting conventions to those of shell.  If no \-s argument is
-found, the
+Set quoting conventions to those of
+.IR shell .
+If the \fB\-s\fR option is not given, the
 .SM BASH
 conventions are used.  Valid arguments are currently
 .RB ' sh '
@@ -142,13 +153,6 @@ conventions are used.  Valid arguments are currently
 and
 .RB ' tcsh '.
 .TP
-.BR \-u , " \-\-unquoted"
-Do not quote the output.  Note that whitespace and special
-(shell\-dependent) characters can cause havoc in this mode (like they
-do with other
-.BR getopt (1)
-implementations).
-.TP
 .BR \-T , " \-\-test"
 Test if your
 .BR getopt (1)
@@ -161,9 +165,15 @@ is set, will return
 .RB ' \-\- '
 and error status 0.
 .TP
+.BR \-u , " \-\-unquoted"
+Do not quote the output.  Note that whitespace and special
+(shell-dependent) characters can cause havoc in this mode (like they
+do with other
+.BR getopt (1)
+implementations).
+.TP
 .BR \-V , " \-\-version"
-Output version information and exit successfully.  No other output is
-generated.
+Display version information and exit.  No other output is generated.
 .SH PARSING
 This section specifies the format of the second part of the
 parameters of
@@ -193,7 +203,7 @@ A simple short option is a
 .RB ' \- '
 followed by a short option character.  If the option has a required
 argument, it may be written directly after the option character or as
-the next parameter (ie.  separated by whitespace on the command
+the next parameter (i.e., separated by whitespace on the command
 line).  If the option has an optional argument, it must be written
 directly after the option character if present.
 .PP
@@ -208,7 +218,7 @@ followed by the long option name.  If the option has a required
 argument, it may be written directly after the long option name,
 separated by
 .RB ' = ',
-or as the next argument (i.e. separated by whitespace on the command
+or as the next argument (i.e., separated by whitespace on the command
 line).  If the option has an optional argument, it must be written
 directly after the long option name, separated by
 .RB ' = ',
@@ -340,8 +350,8 @@ If the first character is
 .RB ' + ',
 or if the environment variable
 .B POSIXLY_CORRECT
-is set, parsing stops as soon as the first non\-option parameter (ie.
-a parameter that does not start with a
+is set, parsing stops as soon as the first non\-option parameter
+(i.e., a parameter that does not start with a
 .RB ' \- ')
 is found that is not an option argument.  The remaining parameters
 are all interpreted as non\-option parameters.
@@ -365,10 +375,11 @@ modifications, and with some advantages.
 .PP
 If the first character of the first parameter of getopt is not a
 .RB ' \- ',
-getopt goes into compatibility mode.  It will interpret its first
+.B getopt
+goes into compatibility mode.  It will interpret its first
 parameter as the string of short options, and all other arguments
-will be parsed.  It will still do parameter shuffling (ie.  all
-non\-option parameters are outputted at the end), unless the
+will be parsed.  It will still do parameter shuffling (i.e., all
+non\-option parameters are output at the end), unless the
 environment variable
 .B POSIXLY_CORRECT
 is set.
@@ -407,7 +418,10 @@ if it is called with
 Example scripts for (ba)sh and (t)csh are provided with the
 .BR getopt (1)
 distribution, and are optionally installed in
-.BR /usr/share/getopt/ .
+.I /usr/share/getopt/
+or
+.I /usr/share/doc/
+in the util-linux subdirectory.
 .SH ENVIRONMENT
 .IP POSIXLY_CORRECT
 This environment variable is examined by the
@@ -425,7 +439,7 @@ to use the first calling format as specified in the
 .SH BUGS
 .BR getopt (3)
 can parse long options with optional arguments that are given an
-empty optional argument (but can not do this for short options).
+empty optional argument (but cannot do this for short options).
 This
 .BR getopt (1)
 treats optional arguments that are empty as if they were not present.
@@ -438,11 +452,11 @@ string).
 Frodo Looijaard
 .ME
 .SH "SEE ALSO"
-.BR getopt (3),
 .BR bash (1),
-.BR tcsh (1).
+.BR tcsh (1),
+.BR getopt (3)
 .SH AVAILABILITY
 The getopt command is part of the util-linux package and is available from
-.UR ftp://\:ftp.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
+.UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
 Linux Kernel Archive
 .UE .