diff options
author | Jim Meyering <jim@meyering.net> | 1994-07-13 13:49:14 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1994-07-13 13:49:14 +0000 |
commit | 5ea8d4e765bcb94873c5fdb816a46acb7606f644 (patch) | |
tree | 322d1c0ac690e665eb48f6a43e83a0440bf68c33 | |
parent | 09ce65ba63fc852c3c01feddc1f22e75891f5e10 (diff) | |
download | gnulib-5ea8d4e765bcb94873c5fdb816a46acb7606f644.tar.gz |
GNU shell utilitiesSHELLUTILS-1_10e
-rw-r--r-- | lib/getopt.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/getopt.c b/lib/getopt.c index 654f761598..48e9a539f3 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -158,6 +158,9 @@ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; + +/* Value of POSIXLY_CORRECT environment variable. */ +static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries @@ -289,6 +292,8 @@ _getopt_initialize (optstring) nextchar = NULL; + posixly_correct = getenv ("POSIXLY_CORRECT"); + /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') @@ -301,7 +306,7 @@ _getopt_initialize (optstring) ordering = REQUIRE_ORDER; ++optstring; } - else if (getenv ("POSIXLY_CORRECT") != NULL) + else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; @@ -605,8 +610,11 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { if (opterr) { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); + else + fprintf (stderr, "%s: invalid option -- %c\n", argv[0], c); } optopt = c; return '?'; |