Fix log filtering logic to work with new regex flag correctly

This commit is contained in:
Ilia Ross
2026-02-08 16:16:57 +02:00
parent 79b5b307ed
commit a655f875cf
2 changed files with 4 additions and 13 deletions

View File

@@ -180,13 +180,8 @@ if (!$follow) {
my $fcmd;
my $context_opts = $has_context ? " -C $context_lines" : "";
if ($cmd =~ /journalctl/) {
if ($use_regex && !$has_context) {
$fcmd = "$cmd --grep $filter";
}
else {
$fcmd = "$cmd | grep -a $grep_mode$context_opts ".
"$dashflag $filter";
}
$fcmd = "$cmd | grep -a $grep_mode$context_opts ".
"$dashflag $filter";
}
else {
$fcmd = "$cat | grep -i -a $grep_mode$context_opts ".

View File

@@ -39,12 +39,8 @@ my $filter = $in{'filter'} ? quotemeta($in{'filter'}) : "";
my $use_regex = $in{'regex'} ? 1 : 0;
my $readcmd = $log->{'cmd'};
if ($filter) {
if ($use_regex) {
$readcmd .= " --grep $filter";
}
else {
$readcmd .= " | grep --line-buffered -F -a -- $filter";
}
my $grep_flag = $use_regex ? "-E" : "-F";
$readcmd .= " | grep --line-buffered -a $grep_flag -- $filter";
}
# Open a pipe to the journalctl command