# HG changeset patch # User Juanma Barranquero # Date 1162468335 0 # Node ID 3e566ec9ef5d787736c7b08d9090284673addd0d # Parent c0e51f9dc9feffeee2e9d00f0815d3cb75149a71 When called with no arguments (not even a filter), show help instead of blindingly dumping every single ChangeLog available. Doc fix. Update version. diff -r c0e51f9dc9fe -r 3e566ec9ef5d lib-src/grep-changelog --- a/lib-src/grep-changelog Thu Nov 02 11:27:45 2006 +0000 +++ b/lib-src/grep-changelog Thu Nov 02 11:52:15 2006 +0000 @@ -36,22 +36,33 @@ @entries); use Getopt::Long; -my $result = GetOptions ("author=s" => \$author, - "text=s" => \$regexp, - "exclude=s" => \$exclude, - "from-date=s" => \$from_date, - "to-date=s" => \$to_date, - "rcs-log" => \$rcs_log, - "with-date" => \$with_date, - "reverse!" => \$reverse, - "version" => \$version, - "help" => \$help); + +my $result; + +if (@ARGV == 0) { + + # No arguments cannot posibly mean "show everything"!! + $result = 0; + +} else { -# If date options are specified, check that they have the format -# YYYY-MM-DD. + $result = GetOptions ("author=s" => \$author, + "text=s" => \$regexp, + "exclude=s" => \$exclude, + "from-date=s" => \$from_date, + "to-date=s" => \$to_date, + "rcs-log" => \$rcs_log, + "with-date" => \$with_date, + "reverse!" => \$reverse, + "version" => \$version, + "help" => \$help); -$result = 0 if $from_date && $from_date !~ /^\d\d\d\d-\d\d-\d\d$/; -$result = 0 if $to_date && $to_date !~ /^\d\d\d\d-\d\d-\d\d$/; + # If date options are specified, check that they have the format + # YYYY-MM-DD. + + $result = 0 if $from_date && $from_date !~ /^\d\d\d\d-\d\d-\d\d$/; + $result = 0 if $to_date && $to_date !~ /^\d\d\d\d-\d\d-\d\d$/; +} # Print usage information and exit when necessary. @@ -77,7 +88,7 @@ --help Print this help If no CHANGELOG is specified scan the files "ChangeLog" and -"ChangeLog.1+" in the current directory. Old-style dates in ChangeLogs +"ChangeLog.N+" in the current directory. Old-style dates in ChangeLogs are not recognized. USAGE exit !$help; @@ -86,7 +97,7 @@ # Print version info and exit if `--version' was specified. if ($version) { - print "0.2\n"; + print "0.3\n"; exit 0; } @@ -233,7 +244,7 @@ # If files were specified on the command line, parse those files in the # order supplied by the user; otherwise parse default files ChangeLog and -# ChangeLog.1+ according to $reverse. +# ChangeLog.NNN according to $reverse. unless (@ARGV > 0) { @ARGV = ("ChangeLog");