summary refs log tree commit diff
path: root/manual/getopt.texi
diff options
context:
space:
mode:
Diffstat (limited to 'manual/getopt.texi')
-rw-r--r--manual/getopt.texi19
1 files changed, 19 insertions, 0 deletions
diff --git a/manual/getopt.texi b/manual/getopt.texi
index f3934d0cfe..aefb034566 100644
--- a/manual/getopt.texi
+++ b/manual/getopt.texi
@@ -71,10 +71,29 @@ string can be followed by a colon (@samp{:}) to indicate that it takes a
 required argument.  If an option character is followed by two colons
 (@samp{::}), its argument is optional; this is a GNU extension.
 
+@code{getopt} has three ways to deal with options that follow
+non-options @var{argv} elements.  The special argument @samp{--} forces
+in all cases the end of option scanning.
+
+@itemize @bullet
+@item
+The default is to permute the contents of @var{argv} while scanning it
+so that eventually all the non-options are at the end.  This allows
+options to be given in any order, even with programs that were not
+written to expect this.
+
+@item
 If the @var{options} argument string begins with a hyphen (@samp{-}), this
 is treated specially.  It permits arguments that are not options to be
 returned as if they were associated with option character @samp{\0}.
 
+@item
+POSIX demands the following behaviour: The first non-option stops option
+processing.  This mode is selected by either setting the environment
+variable @code{POSIXLY_CORRECT} or beginning the @var{options} argument
+string with a plus sign (@samp{+}).
+@end itemize
+
 The @code{getopt} function returns the option character for the next
 command line option.  When no more option arguments are available, it
 returns @code{-1}.  There may still be more non-option arguments; you