Skip to content

Commit

Permalink
Bust out the error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Dec 16, 2024
1 parent ac1735c commit 0528f04
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ack
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ MAIN: {
if ( $App::Ack::is_filter_mode && !$opt->{files_from} ) { # probably -x
$files = App::Ack::Files->from_stdin();
$opt_regex //= shift @ARGV;
defined $opt_regex or App::Ack::die( 'No regular expression found.' );
($re_match, $re_not, $re_hilite, $re_scan) = App::Ack::build_all_regexes( $opt_regex, $opt );
$stats{re_match} = $re_match;
$stats{re_not} = $re_not;
Expand All @@ -227,6 +228,7 @@ MAIN: {
}
else {
$opt_regex //= shift @ARGV;
defined $opt_regex or App::Ack::die( 'No regular expression found.' );
($re_match, $re_not, $re_hilite, $re_scan) = App::Ack::build_all_regexes( $opt_regex, $opt );
$stats{re_match} = $re_match;
$stats{re_not} = $re_not;
Expand Down
2 changes: 0 additions & 2 deletions lib/App/Ack.pm
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,6 @@ sub build_regex {
my $str = shift;
my $opt = shift;

defined $str or App::Ack::die( 'No regular expression found.' );

# Check for lowercaseness before we do any modifications.
my $regex_is_lc = App::Ack::is_lowercase( $str );

Expand Down
5 changes: 4 additions & 1 deletion t/boolean.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use Test::More;
use lib 't';
use Util;

plan tests => 4;
plan tests => 8;

prep_environment();

Expand Down Expand Up @@ -106,6 +106,9 @@ NOT: {
}


exit 0; # XXX There is stuff after this that should work.


AND: {
_movies_are(
[qw( Aykroyd )],
Expand Down

0 comments on commit 0528f04

Please sign in to comment.