Skip to content

Commit d7bb1f5

Browse files
YHNdnzjkeszybz
authored andcommitted
journalctl: fix when --grep is used with --follow
Follow-up for #25147 (db46919) --follow sets arg_lines to 10, which breaks --grep as the latter implies --reverse. So let's not set --reverse if --follow is used. (cherry picked from commit c673fd5) Should fix https://bugzilla.redhat.com/show_bug.cgi?id=2215304.
1 parent 5b3affc commit d7bb1f5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/journal/journalctl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,8 +1089,10 @@ static int parse_argv(int argc, char *argv[]) {
10891089
return r;
10901090

10911091
/* When --grep is used along with --lines, we don't know how many lines we can print.
1092-
* So we search backwards and count until enough lines have been printed or we hit the head. */
1093-
if (arg_lines >= 0)
1092+
* So we search backwards and count until enough lines have been printed or we hit the head.
1093+
* An exception is that --follow might set arg_lines, so let's not imply --reverse
1094+
* if that is specified. */
1095+
if (arg_lines >= 0 && !arg_follow)
10941096
arg_reverse = true;
10951097
}
10961098

0 commit comments

Comments
 (0)