with missing argument, and support `--'.
* aclocal.in (parse_arguments): Diagnose options with missing
argument.
* tests/aclocal.test: More checks.
* tests/automake.test: New file.
* tests/postprog.test: Use `--' for fun.
* tests/Makefile.am (TESTS): Add automake.test.
Report from Eric Blake.
2004-11-21 Alexandre Duret-Lutz <adl@gnu.org>
+ * automake.in (parse_arguments): Diagnose empty arguments, options
+ with missing argument, and support `--'.
+ * aclocal.in (parse_arguments): Diagnose options with missing
+ argument.
+ * tests/aclocal.test: More checks.
+ * tests/automake.test: New file.
+ * tests/postprog.test: Use `--' for fun.
+ * tests/Makefile.am (TESTS): Add automake.test.
+ Report from Eric Blake.
+
* lib/am/progs.am (installcheck-%DIR%PROGRAMS): Run programs with
/dev/null as input, so we do not hang on programs that read their
input without supporting --help and --version.
'output=s' => \$output_file,
'print-ac-dir' => \$print_and_exit,
'verbose' => sub { setup_channel 'verb', silent => 0; },
- 'W|warnings:s' => \&parse_warnings,
+ 'W|warnings=s' => \&parse_warnings,
);
use Getopt::Long;
Getopt::Long::config ("bundling", "pass_through");
if (@ARGV)
{
- fatal ("unrecognized option `$ARGV[0]'\n"
- . "Try `$0 --help' for more information.");
+ my %argopts;
+ for my $k (keys %cli_options)
+ {
+ if ($k =~ /(.*)=s$/)
+ {
+ map { $argopts{(length ($_) == 1)
+ ? "-$_" : "--$_" } = 1; } (split (/\|/, $1));
+ }
+ }
+ if (exists $argopts{$ARGV[0]})
+ {
+ fatal ("option `$ARGV[0]' requires an argument\n"
+ . "Try `$0 --help' for more information.");
+ }
+ else
+ {
+ fatal ("unrecognized option `$ARGV[0]'\n"
+ . "Try `$0 --help' for more information.");
+ }
}
if ($print_and_exit)
my $cli_where = new Automake::Location;
my %cli_options =
(
- 'libdir:s' => \$libdir,
+ 'libdir=s' => \$libdir,
'gnu' => sub { set_strictness ('gnu'); },
'gnits' => sub { set_strictness ('gnits'); },
'cygnus' => sub { set_global_option ('cygnus', $cli_where); },
$cli_where); },
'no-force' => sub { $force_generation = 0; },
'f|force-missing' => \$force_missing,
- 'o|output-dir:s' => \$output_directory,
+ 'o|output-dir=s' => \$output_directory,
'a|add-missing' => \$add_missing,
'c|copy' => \$copy_missing,
'v|verbose' => sub { setup_channel 'verb', silent => 0; },
- 'W|warnings:s' => \&parse_warnings,
+ 'W|warnings=s' => \&parse_warnings,
# These long options (--Werror and --Wno-error) for backward
# compatibility. Use -Werror and -Wno-error today.
'Werror' => sub { parse_warnings 'W', 'error'; },
$output_directory = '.';
}
- my $errspec = 0;
- foreach my $arg (@ARGV)
+ return unless @ARGV;
+
+ if ($ARGV[0] =~ /^-./)
{
- if ($arg =~ /^-./)
+ my %argopts;
+ for my $k (keys %cli_options)
+ {
+ if ($k =~ /(.*)=s$/)
+ {
+ map { $argopts{(length ($_) == 1)
+ ? "-$_" : "--$_" } = 1; } (split (/\|/, $1));
+ }
+ }
+ if ($ARGV[0] eq '--')
+ {
+ shift @ARGV;
+ }
+ elsif (exists $argopts{$ARGV[0]})
{
- fatal ("unrecognized option `$arg'\n"
+ fatal ("option `$ARGV[0]' requires an argument\n"
. "Try `$0 --help' for more information.");
}
+ else
+ {
+ fatal ("unrecognized option `$ARGV[0]'.\n"
+ . "Try `$0 --help' for more information.");
+ }
+ }
+
+ my $errspec = 0;
+ foreach my $arg (@ARGV)
+ {
+ fatal ("empty argument\nTry `$0 --help' for more information.")
+ if ($arg eq '');
# Handle $local:$input syntax.
my ($local, @rest) = split (/:/, $arg);
autohdr2.test \
autohdr3.test \
autohdr4.test \
+automake.test \
auxdir.test \
auxdir2.test \
auxdir3.test \
autohdr2.test \
autohdr3.test \
autohdr4.test \
+automake.test \
auxdir.test \
auxdir2.test \
auxdir3.test \
$ACLOCAL --output=fred
test -f fred
+$ACLOCAL --output 2>stderr && exit 1
+grep 'option.*--output.*an argument' stderr
+grep help stderr
+
$ACLOCAL --unknown-option 2>stderr && exit 1
+grep 'unrecognized.*--unknown-option' stderr
grep help stderr
test "`$ACLOCAL --print-ac-dir`" = "$testaclocaldir"
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2004 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test Automake's command-line options.
+. ./defs || exit 1
+
+set -e
+
+$AUTOMAKE --help
+$AUTOMAKE --version
+AUTOMAKE_fails --voo
+grep 'unrecognized option.*--voo' stderr
+AUTOMAKE_fails -- --voo
+grep 'input file.*--voo' stderr
+AUTOMAKE_fails ''
+grep 'empty argument' stderr
+AUTOMAKE_fails -W
+grep 'option.*-W.*requires an argument' stderr
+AUTOMAKE_fails --warnings
+grep 'option.*--warning.*requires an argument' stderr
+AUTOMAKE_fails --warnings --help
+grep 'unknown warning.*--help' stderr
#! /bin/sh
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2004 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
$ACLOCAL || exit 1
$AUTOCONF || exit 1
-$AUTOMAKE myMakefile || exit 1
+$AUTOMAKE -- myMakefile || exit 1
mv myMakefile.in myMakefile.old
echo '# Post-processed by post-processor 3.14.' > myMakefile.in