GNU bug report logs - #20514
Patch to tie --help and --version behavior to POSIXLY_CORRECT

Previous Next

Package: coreutils;

Reported by: Shawn McMahon <syberghost <at> gmail.com>

Date: Wed, 6 May 2015 15:53:03 UTC

Severity: normal

Tags: wontfix

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Shawn McMahon <syberghost <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: Patch to tie --help and --version behavior to POSIXLY_CORRECT
Date: Wed, 6 May 2015 11:40:20 -0400
[Message part 1 (text/plain, inline)]
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 <syberghost <at> gmail.com>
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)
[Message part 2 (text/html, inline)]

This bug report was last modified 10 years and 73 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.