[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug in option parsing (second patch)
From: |
Alexandre Duret-Lutz |
Subject: |
Re: bug in option parsing (second patch) |
Date: |
Mon, 22 Nov 2004 01:03:19 +0100 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) |
>>> "Eric" == Eric Blake <address@hidden> writes:
[...]
Eric> Third, it does not treat --ver as ambiguous. Other GNU programs
Eric> accept all non-ambiguous prefixes of long option names, but report an
Eric> error when two or more options share that prefix.
Eric> $ ls --al #--all or --almost-all
Eric> ls: option `--al' is ambiguous
Eric> Try `ls --help' for more information.
Eric> $ automake --ver
Eric> automake: reading autoconf [... running --verbose, rather than --version]
[...]
I first thought this was a Getopt::Long bug too, but it was just caused
by the two-phase argument parsing logic used.
I'm checking this in on HEAD.
2004-11-22 Alexandre Duret-Lutz <address@hidden>
* aclocal.in (parse_arguments): Diagnose abbreviation ambiguous with
--help or --version.
* automake.in (parse_arguments): Likewise.
* tests/aclocal.test, tests/automake.test: Check this.
Report from Eric Blake.
Index: aclocal.in
===================================================================
RCS file: /cvs/automake/automake/aclocal.in,v
retrieving revision 1.119
diff -u -r1.119 aclocal.in
--- aclocal.in 21 Nov 2004 23:31:43 -0000 1.119
+++ aclocal.in 22 Nov 2004 00:00:29 -0000
@@ -659,9 +659,10 @@
or exit 1;
@ARGV = @ARGV_backup;
- # Now *really* process the options. This time we know
- # that --help and --version are not present.
- Getopt::Long::GetOptions %cli_options
+ # Now *really* process the options. This time we know that --help
+ # and --version are not present, but we specify them nonetheless so
+ # that ambiguous abbreviation are diagnosed.
+ Getopt::Long::GetOptions %cli_options, 'version' => sub {}, 'help' => sub {}
or exit 1;
if (@ARGV)
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1588
diff -u -r1.1588 automake.in
--- automake.in 21 Nov 2004 23:31:43 -0000 1.1588
+++ automake.in 22 Nov 2004 00:00:30 -0000
@@ -7474,9 +7474,10 @@
or exit 1;
@ARGV = @ARGV_backup;
- # Now *really* process the options. This time we know
- # that --help and --version are not present.
- Getopt::Long::GetOptions %cli_options
+ # Now *really* process the options. This time we know that --help
+ # and --version are not present, but we specify them nonetheless so
+ # that ambiguous abbreviation are diagnosed.
+ Getopt::Long::GetOptions %cli_options, 'version' => sub {}, 'help' => sub {}
or exit 1;
if (defined $output_directory)
Index: tests/aclocal.test
===================================================================
RCS file: /cvs/automake/automake/tests/aclocal.test,v
retrieving revision 1.8
diff -u -r1.8 aclocal.test
--- tests/aclocal.test 21 Nov 2004 23:31:45 -0000 1.8
+++ tests/aclocal.test 22 Nov 2004 00:00:30 -0000
@@ -35,4 +35,10 @@
grep 'unrecognized.*--unknown-option' stderr
grep help stderr
+$ACLOCAL --ver 2>stderr && exit 1
+grep 'unrecognized.*--ver' stderr
+grep help stderr
+
+$ACLOCAL --versi
+
test "`$ACLOCAL --print-ac-dir`" = "$testaclocaldir"
Index: tests/automake.test
===================================================================
RCS file: /cvs/automake/automake/tests/automake.test,v
retrieving revision 1.1
diff -u -r1.1 automake.test
--- tests/automake.test 21 Nov 2004 23:31:45 -0000 1.1
+++ tests/automake.test 22 Nov 2004 00:00:30 -0000
@@ -37,3 +37,6 @@
grep 'option.*--warning.*requires an argument' stderr
AUTOMAKE_fails --warnings --help
grep 'unknown warning.*--help' stderr
+AUTOMAKE_fails --ver
+grep 'unrecognized option.*--ver' stderr
+$AUTOMAKE --vers
--
Alexandre Duret-Lutz