GNU bug report logs -
#20514
Patch to tie --help and --version behavior to POSIXLY_CORRECT
Previous Next
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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20514 in the body.
You can then email your comments to 20514 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#20514
; Package
coreutils
.
(Wed, 06 May 2015 15:53:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Shawn McMahon <syberghost <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Wed, 06 May 2015 15:53:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[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)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#20514
; Package
coreutils
.
(Wed, 06 May 2015 16:14:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 20514 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 05/06/2015 09:40 AM, Shawn McMahon wrote:
> 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\
Backwards. The point of POSIXLY_CORRECT is that if it is set, we
conform to POSIX, if it is unset, then we have chosen to take on
intentionally non-compliant behavior. If we make this change (and I'm
90-10 against changing anything at all), then:
/bin/test --help
would change to output help (as that is the non-compliant behavior), while
POSIXLY_CORRECT=1 /bin/test --help
would be the one that silently gives 0 status (because that is what
POSIX mandates).
But the reason I'm against changing it is that checking an arbitrary
string for empty content is SUCH a common operation that making certain
arbitrary strings special is more likely to break behavior of
unsuspecting programs. The escape hatch of "well, you should have set
POSIXLY_CORRECT" is unappealing, as turning on POSIX compliance often
cripples other non-standard extensions that people tend to rely on.
>
> - if (LBRACKET)
> + if (LBRACKET || getenv ("POSIXLY_CORRECT"))
Again, if we make the change, this logic is backwards (it should be
checking if POSIXLY_CORRECT is not set).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#20514
; Package
coreutils
.
(Wed, 06 May 2015 16:18:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 20514 <at> debbugs.gnu.org (full text, mbox):
On 06/05/15 16:40, Shawn McMahon wrote:
> 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
Your patch logic is confusing me.
I presume you mean to have `test --help` output usage by default?
If so I'm not sure it's appropriate to change that.
Consider a script like the following, which would spuriously output the version.
option='--version'
test "$option" || { usage; exit 1; }
cmd $option
thanks,
Pádraig
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#20514
; Package
coreutils
.
(Wed, 06 May 2015 16:28:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 20514 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Wow, how embarrassing. Yes, I clearly have my logic backwards on that. :(
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#20514
; Package
coreutils
.
(Wed, 06 May 2015 16:32:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 20514 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I got my patch logic backwards and you're right, that's way too common a
use case to break.
You can close this wontfix. Sorry to have wasted folks' time on this.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#20514
; Package
coreutils
.
(Wed, 06 May 2015 16:37:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 20514 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 05/06/2015 10:13 AM, Eric Blake wrote:
> intentionally non-compliant behavior. If we make this change (and I'm
> 90-10 against changing anything at all), then:
>
> But the reason I'm against changing it is that checking an arbitrary
> string for empty content is SUCH a common operation that making certain
> arbitrary strings special is more likely to break behavior of
> unsuspecting programs. The escape hatch of "well, you should have set
> POSIXLY_CORRECT" is unappealing, as turning on POSIX compliance often
> cripples other non-standard extensions that people tend to rely on.
Another argument against the change: This proposal would only affect
/bin/test (or 'env test', or other constructs that force resolution
through PATH). However, most shells have 'test' as a builtin, so it
will NOT impact those instances. Having coreutils needlessly differ
from other implementations is undesirable. If you can first get 'bash'
patched to do this, you might have a stronger argument, but bash is one
of those programs where the mere act of setting POSIXLY_CORRECT in the
environment changes a lot about how bash behaves.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
Added tag(s) wontfix.
Request was from
Pádraig Brady <P <at> draigBrady.com>
to
control <at> debbugs.gnu.org
.
(Wed, 06 May 2015 16:41:03 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
20514 <at> debbugs.gnu.org and Shawn McMahon <syberghost <at> gmail.com>
Request was from
Pádraig Brady <P <at> draigBrady.com>
to
control <at> debbugs.gnu.org
.
(Wed, 06 May 2015 16:41:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#20514
; Package
coreutils
.
(Wed, 06 May 2015 16:43:02 GMT)
Full text and
rfc822 format available.
Message #27 received at 20514 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Wed, May 6, 2015 at 12:36 PM, Eric Blake <eblake <at> redhat.com> wrote:
>
> Another argument against the change: This proposal would only affect
> /bin/test (or 'env test', or other constructs that force resolution
> through PATH). However, most shells have 'test' as a builtin, so it
> will NOT impact those instances. Having coreutils needlessly differ
> from other implementations is undesirable. If you can first get 'bash'
> patched to do this, you might have a stronger argument, but bash is one
> of those programs where the mere act of setting POSIXLY_CORRECT in the
> environment changes a lot about how bash behaves.
bash is actually worse, since "[ --help" doesn't work with the builtin.
But agreed on your point.
[Message part 2 (text/html, inline)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 04 Jun 2015 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 10 years and 60 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.