mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
remove exit 1
from search_pattern_in_file.inc
it broke tests on Windows. Use SEARCH_ABORT instead. also, remove redundant features and simplify
This commit is contained in:
@@ -48,15 +48,12 @@
|
||||
# Created: 2011-11-11 mleich
|
||||
#
|
||||
|
||||
--error 0,1
|
||||
perl;
|
||||
use strict;
|
||||
die "SEARCH_FILE not set" unless $ENV{SEARCH_FILE};
|
||||
my @search_files= glob($ENV{SEARCH_FILE});
|
||||
my $search_pattern= $ENV{SEARCH_PATTERN} or die "SEARCH_PATTERN not set";
|
||||
my $search_range= $ENV{SEARCH_RANGE};
|
||||
my $silent= $ENV{SEARCH_SILENT};
|
||||
my $search_result= 0;
|
||||
my $content;
|
||||
foreach my $search_file (@search_files) {
|
||||
open(FILE, '<', $search_file) || die("Can't open file $search_file: $!");
|
||||
@@ -81,39 +78,18 @@ perl;
|
||||
$content.= $file_content;
|
||||
}
|
||||
my @matches= ($content =~ /$search_pattern/gs);
|
||||
my $res;
|
||||
if (@matches)
|
||||
{
|
||||
$res="FOUND " . scalar(@matches);
|
||||
$search_result= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$res= "NOT FOUND";
|
||||
}
|
||||
my $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND";
|
||||
|
||||
$ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1};
|
||||
|
||||
if (!$silent || $search_result)
|
||||
{
|
||||
if ($ENV{SEARCH_OUTPUT} eq "matches")
|
||||
{
|
||||
foreach (@matches)
|
||||
{
|
||||
print $_ . "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
|
||||
if ($ENV{SEARCH_OUTPUT} eq "matches") {
|
||||
foreach (@matches) {
|
||||
print $_ . "\n";
|
||||
}
|
||||
}
|
||||
die "$ENV{SEARCH_ABORT}\n"
|
||||
if $ENV{SEARCH_ABORT} && $res =~ /^$ENV{SEARCH_ABORT}/;
|
||||
exit($search_result != 1);
|
||||
elsif ($ENV{SEARCH_ABORT} and $res =~ /^$ENV{SEARCH_ABORT}/) {
|
||||
die "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
|
||||
} else {
|
||||
print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
|
||||
}
|
||||
EOF
|
||||
|
||||
let $SEARCH_RESULT= 1; # Found pattern
|
||||
if ($errno)
|
||||
{
|
||||
let $SEARCH_RESULT= 0; # Did not find pattern
|
||||
}
|
||||
|
Reference in New Issue
Block a user