+2011-01-14 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ getopt: fix diagnostic for missing mandatory option argument
+ Before this change, an incorrect command line usage:
+ "autom4te --output"
+ triggered broken diagnostic like:
+ "autom4te: unrecognized option `--output'"
+ instead of the expected and correct:
+ "autom4te: option `--output' requires an argument"
+ * lib/Autom4te/General.pm (getopt): Give correct diagnostic in
+ case of usage errors due to missing arguments for options for
+ which they are mandatory. Code basically copied from automake's
+ 'parse_arguments' private subroutine.
+
2012-01-05 Paul Eggert <eggert@cs.ucla.edu>
doc: mention Bash 2.03 bug with backslash-newline
GetOptions (%option)
or exit 1;
- foreach (grep { /^-./ } @ARGV)
+ # FIXME: Lot of code duplication with automake here. It would probably
+ # be best to generalize our getopt() func and rip it out in a new module
+ # from which automake can sync.
+ if ($ARGV[0] =~ /^-./)
{
- print STDERR "$0: unrecognized option `$_'\n";
- print STDERR "Try `$0 --help' for more information.\n";
- exit (1);
+ my %argopts;
+ for my $k (keys %option)
+ {
+ if ($k =~ /(.*)=s$/)
+ {
+ map { $argopts{(length ($_) == 1)
+ ? "-$_" : "--$_" } = 1; } (split (/\|/, $1));
+ }
+ }
+ if ($ARGV[0] eq '--')
+ {
+ shift @ARGV;
+ }
+ elsif (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.");
+ }
}
push @ARGV, '-'