about summary refs log tree commit diff
path: root/posix
diff options
context:
space:
mode:
Diffstat (limited to 'posix')
-rw-r--r--posix/getopt.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/posix/getopt.c b/posix/getopt.c
index 4e11744db8..24da4d3aa9 100644
--- a/posix/getopt.c
+++ b/posix/getopt.c
@@ -3,7 +3,7 @@
    "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
    before changing it!
 
-   Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95
+   Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 1996
    	Free Software Foundation, Inc.
 
 This file is part of the GNU C Library.  Its master source is NOT part of
@@ -435,6 +435,13 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
     {
       /* Advance to the next ARGV-element.  */
 
+      /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
+	 moved back by the user (who may also have changed the arguments).  */
+      if (last_nonopt > optind)
+	last_nonopt = optind;
+      if (first_nonopt > optind)
+	first_nonopt = optind;
+
       if (ordering == PERMUTE)
 	{
 	  /* If we have just processed some options following some non-options,