bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20514: Patch to tie --help and --version behavior to POSIXLY_CORRECT


From: Shawn McMahon
Subject: bug#20514: Patch to tie --help and --version behavior to POSIXLY_CORRECT
Date: Wed, 6 May 2015 11:40:20 -0400

The following patch to "test" ties the behavior of "--help" and "--version" to POSIXLY_CORRECT. I don't believe this breaks anything, and if it does it can by fixed by setting the time-honored variable. This will solve the problem of users occasionally being confused by this behavior, which has happened even recently to coreutils developers. See for example:

http://lists.gnu.org/archive/html/coreutils/2015-03/msg00007.html


Proposed ChangeLog entry:

Author: Shawn McMahon <address@hidden>
Date:   Tue May 5 20:32:00 2015 -0400

    test: tie --help and --version behavior to POSIXLY_CORRECT


diff --git a/a/src/test.c b/b/src/test.c
index 80cc679..3e73bb9 100644
--- a/a/src/test.c
+++ b/b/src/test.c
@@ -789,6 +789,7 @@ INTEGER may also be -l STRING, which evaluates to the length of STRING.\n\
 \n\
 NOTE: [ honors the --help and --version options, but test does not.\n\
 test treats each of those as it treats any other nonempty STRING.\n\
+If POSIXLY_CORRECT is set, test honors both.\n\
 "), stdout);
       printf (USAGE_BUILTIN_WARNING, _("test and/or ["));
       emit_ancillary_info (PROGRAM_NAME);
@@ -836,12 +837,12 @@ main (int margc, char **margv)
 
   argv = margv;
 
-  if (LBRACKET)
+  if (LBRACKET || getenv ("POSIXLY_CORRECT"))
     {
       /* Recognize --help or --version, but only when invoked in the
-         "[" form, when the last argument is not "]".  Use direct
-         parsing, rather than parse_long_options, to avoid accepting
-         abbreviations.  POSIX allows "[ --help" and "[ --version" to
+         "[" form, when the last argument is not "]", or when POSIXLY_CORRECT
+         is set. Use direct parsing, rather than parse_long_options, to avoid
+         accepting abbreviations.  POSIX allows "[ --help" and "[ --version" to
          have the usual GNU behavior, but it requires "test --help"
          and "test --version" to exit silently with status 0.  */
       if (margc == 2)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]