Subject: | VersionMessage ignores -output argument |
If you call the VersionMessage subroutine directly, the -output argument seems to be pretty much ignored. Reading the code, it looks like the intent was to compute the output handle by performing a '||' on the -output argument and the results of a '?:'. Unfortunately the '?:' binds more loosely than the '||' (see perlop), so the result is going to be either the second or third operand of the '?:' no matter what value is given for -output.
The attached files are:
* Getopt-Long.patch, a patch that restores what I believe is the intended functionality by placing parentheses around the trinary operation;
* check, a small Perl script that demonstrates the behavior (or lack thereof).
I would have done a test, but I was not brave (or foolish) enough to write a test that needs to run under Perl 5.004.
I have called this unimportant because if it was causing anyone any serious problem you would have gotten a report on this long ago.
Subject: | Getopt-Long.patch |
--- lib/Getopt/Long.old 2016-04-13 13:19:47.000000000 -0400
+++ lib/Getopt/Long.pm 2016-04-13 13:56:03.000000000 -0400
@@ -1451,7 +1451,7 @@
my $v = $main::VERSION;
my $fh = $pa->{-output} ||
- ($pa->{-exitval} eq "NOEXIT" || $pa->{-exitval} < 2) ? \*STDOUT : \*STDERR;
+ ( ($pa->{-exitval} eq "NOEXIT" || $pa->{-exitval} < 2) ? \*STDOUT : \*STDERR );
print $fh (defined($pa->{-message}) ? $pa->{-message} : (),
$0, defined $v ? " version $v" : (),
Subject: | check |
Message body not shown because it is not plain text.