]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(main): Recognize --help and --version even if POSIXLY_CORRECT is set.
authorJim Meyering <jim@meyering.net>
Thu, 17 Jun 2004 14:34:07 +0000 (14:34 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 17 Jun 2004 14:34:07 +0000 (14:34 +0000)
src/true.c
src/yes.c

index e4508cbf113b97e38a355b8583e4792ec55357f4..192003b67d3f1ecede0f51e39a4e71dcf71d3bd2 100644 (file)
@@ -56,8 +56,8 @@ main (int argc, char **argv)
   atexit (close_stdout);
 
   /* Recognize --help or --version only if it's the only command-line
-     argument and if POSIXLY_CORRECT is not set.  */
-  if (argc == 2 && getenv ("POSIXLY_CORRECT") == NULL)
+     argument.  */
+  if (argc == 2)
     {
       if (STREQ (argv[1], "--help"))
        usage (EXIT_SUCCESS);
index f6f26e5a6de1ecc79a3121fa169828d1f080ef53..56b15f7363b73870b67ba2b8f44a1923490e4eec 100644 (file)
--- a/src/yes.c
+++ b/src/yes.c
@@ -71,10 +71,16 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  /* Don't recognize --help or --version if POSIXLY_CORRECT is set.  */
-  if (getenv ("POSIXLY_CORRECT") == NULL)
-    parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
-                       usage, AUTHORS, (char const *) NULL);
+  parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
+                     usage, AUTHORS, (char const *) NULL);
+
+  /* The above handles --help and --version.
+     Since there is no other invocation of getopt, handle `--' here.  */
+  if (1 < argc && STREQ (argv[1], "--"))
+    {
+      --argc;
+      ++argv;
+    }
 
   if (argc == 1)
     {