summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-06-17 14:34:07 +0000
committerJim Meyering <jim@meyering.net>2004-06-17 14:34:07 +0000
commit72f51d66bf8e5364edfa0975c96ddebcaefd089e (patch)
tree1403f915dc59d87c39c34ff9260439b9c04c35a4
parent7870fa108121ddc3d4aa3ae252250040638a4f42 (diff)
downloadcoreutils-72f51d66bf8e5364edfa0975c96ddebcaefd089e.tar.xz
(main): Recognize --help and --version even if POSIXLY_CORRECT is set.
-rw-r--r--src/true.c4
-rw-r--r--src/yes.c14
2 files changed, 12 insertions, 6 deletions
diff --git a/src/true.c b/src/true.c
index e4508cbf1..192003b67 100644
--- a/src/true.c
+++ b/src/true.c
@@ -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);
diff --git a/src/yes.c b/src/yes.c
index f6f26e5a6..56b15f736 100644
--- 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)
{