Fix sloppy Getopt::Long.
PATCH 1/1 Fix sloppy Getopt::Long.
Getopt-Long v2.38 is much stricter about sloppy getopt usage. The trailing pipe causes git-svn testcases to fail for all of the --stdin argument calls.
===
Should be applied to both the stable 1.6.2.x tree and the new 1.6.3 tree.
--- git-svn.perl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
git-svn.perl +1 -1
@@ -147,7 +147,7 @@ my %cmd = ( 'dry-run|n' => \$_dry_run } ], 'set-tree' => [ \&cmd_set_tree, "Set an SVN repository to a git tree-ish", - { 'stdin|' => \$_stdin, %cmt_opts, %fc_opts, } ], + { 'stdin' => \$_stdin, %cmt_opts, %fc_opts, } ], 'create-ignore' => [ \&cmd_create_ignore, 'Create a .gitignore per svn:ignore', { 'revision|r=i' => \$_revision
Signature · 1 line
1.6.2.3
Quoted 3 lines · Robin H. Johnson
Getopt-Long v2.38 is much stricter about sloppy getopt usage. The trailing pipe causes git-svn testcases to fail for all of the --stdin argument calls.
I am not objecting at all; just asking for clarification.
git-svn.perl my %cmd = ( · line 150
Quoted 2 lines
git-svn.perl +1
-1- { 'stdin|' => \$_stdin, %cmt_opts, %fc_opts, } ], + { 'stdin' => \$_stdin, %cmt_opts, %fc_opts, } ],
Is this "pipe" supposed to be followed by an alternative spelling of the option, as in
'stdin|standard-input' => \$_stdin, ...
and is the sloppyness that it would be crazy to accept either --stdin or just -- (without actual option name) for this option?
Could an older version of Getopt::Long() have accepted
$ command --foo --bar - other args
to set $_stdin to true with that "sloppy" syntax? If so people could have relied on such a behaviour, which is a bit worrying.
Quoted 6 lines · Junio C Hamano
Quoted 3 lines · Robin H. Johnson
Getopt-Long v2.38 is much stricter about sloppy getopt usage. The trailing pipe causes git-svn testcases to fail for all of the --stdin argument calls.
Quoted 8 lines
I am not objecting at all; just asking for clarification.
git-svn.perl my %cmd = ( · line 150
Quoted 2 lines
git-svn.perl +1
-1- { 'stdin|' => \$_stdin, %cmt_opts, %fc_opts, } ], + { 'stdin' => \$_stdin, %cmt_opts, %fc_opts, } ],Is this "pipe" supposed to be followed by an alternative spelling of the option, as in
'stdin|standard-input' => \$_stdin, ...
Yes. Short form or alternative long form.
Quoted 2 lines
and is the sloppyness that it would be crazy to accept either --stdin or just -- (without actual option name) for this option?
Within the main loop, both '--' and '-' are treated as special cases earlier on before the matching of options is done. '--' is the explicit separator, while '-' is an argument (or a value to an option), not an option in itself.
Quoted 6 lines
Could an older version of
Getopt::Long()have accepted$ command --foo --bar - other argsto set $_stdin to true with that "sloppy" syntax? If so people could have relied on such a behaviour, which is a bit worrying.
As far as I can follow in the Getopt::Long code, with the old case of 'stdin|', the empty string case would never have matched anyway.
The v2.38 change in respect to this is not described in the upstream CHANGES, but boils down to this single modification:
Getopt-Long-2.38/lib/Getopt/Long.pm:
@@ -777,7 +776,7 @@
# Option name
(?: \w+[-\w]* )
# Alias names, or "?"
- (?: \| (?: \? | \w[-\w]* )? )*
+ (?: \| (?: \? | \w[-\w]* ) )*
)?Signature · 4 lines
Robin Hugh Johnson Gentoo Linux Developer & Infra Guy E-Mail : [email protected] GnuPG FP : 11AC BA4F 4778 E3F6 E4ED F38E B27B 944E 3488 4E85
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 16 lines · Eric Wong
Quoted 9 lines · Junio C Hamano
Quoted 5 lines · Robin H. Johnson
Getopt-Long v2.38 is much stricter about sloppy getopt usage. The trailing pipe causes git-svn testcases to fail for all of the --stdin argument calls.
Signed-off-by Robin H. Johnson <[email protected]>Eric, I'll take this directly to my tree. Ok?
The empty "" after the "|" was intended for the set-tree command to take a lone "-" as a parameter to also mean "--stdin".
The following should work, too, but I don't have time to test right now:
Review
Quoted 2 lines
(quoted diff) +2
-0+ { '' => \$_stdin, 'stdin' => \$_stdin, + %cmt_opts, %fc_opts, } ],
I confirm that it does correctly set the $_stdin variable (tested briefly).
Testcase:
=====
use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/; my $_stdin;
my $rc = GetOptions( 'stdin' => \$_stdin, '' => \$_stdin); printf "rc:%s s:%s\n",$rc,$_stdin;
=====
Signature · 4 lines
Robin Hugh Johnson Gentoo Linux Developer & Infra Guy E-Mail : [email protected] GnuPG FP : 11AC BA4F 4778 E3F6 E4ED F38E B27B 944E 3488 4E85
Quoted 15 lines · Robin H. Johnson
Quoted 14 lines · Eric Wong
Quoted 9 lines · Junio C Hamano
Quoted 5 lines · Robin H. Johnson
Getopt-Long v2.38 is much stricter about sloppy getopt usage. The trailing pipe causes git-svn testcases to fail for all of the --stdin argument calls.
Signed-off-by Robin H. Johnson <[email protected]>Eric, I'll take this directly to my tree. Ok?
The empty "" after the "|" was intended for the set-tree command to take a lone "-" as a parameter to also mean "--stdin".
Quoted 6 lines
Review
Quoted 4 lines
The following should work, too, but I don't have time to test right now:
(quoted diff) +2
-0+ { '' => \$_stdin, 'stdin' => \$_stdin, + %cmt_opts, %fc_opts, } ],I confirm that it does correctly set the $_stdin variable (tested briefly).
Wait a minute. Do you mean we would also need the above "explicit empty argument sets $_stdin"? Wasn't it your earlier analysis/claim that the caller already takes care of a lone "-"?
Or do you mean "yes it would also work but it is not necessary"?
Quoted 7 lines · Junio C Hamano
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ { '' => \$_stdin, 'stdin' => \$_stdin, + %cmt_opts, %fc_opts, } ],I confirm that it does correctly set the $_stdin variable (tested briefly).
Wait a minute. Do you mean we would also need the above "explicit empty argument sets $_stdin"? Wasn't it your earlier analysis/claim that the caller already takes care of a lone "-"?
I'd originally considered a single '-' as an argument not an option, meaning stdin, not being processed within the getopt framework, but instead being handled later.
Quoted 1 line
Or do you mean "yes it would also work but it is not necessary"?
Using Eric's change makes it explicit what is expected: Passing '--stdin' is the same as passing '-'.
Signature · 4 lines
Robin Hugh Johnson Gentoo Linux Developer & Infra Guy E-Mail : [email protected] GnuPG FP : 11AC BA4F 4778 E3F6 E4ED F38E B27B 944E 3488 4E85