Mercurial > hg > octave-lyh > gnulib-hg
changeset 225:ed5f0b3d4c40
GNU shell utilities
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Wed, 13 Jul 1994 13:49:14 +0000 |
parents | c2edb19de896 |
children | 74478d22a1fe |
files | lib/getopt.c |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/getopt.c +++ b/lib/getopt.c @@ -158,6 +158,9 @@ { 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 @@ nextchar = NULL; + posixly_correct = getenv ("POSIXLY_CORRECT"); + /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') @@ -301,7 +306,7 @@ 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 @@ { 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 '?';