Skip to content

Commit e7ff82f

Browse files
YHNdnzjbluca
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. (cherry picked from commit d7bb1f5)
1 parent a43f101 commit e7ff82f

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
@@ -1090,8 +1090,10 @@ static int parse_argv(int argc, char *argv[]) {
10901090
return r;
10911091

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

0 commit comments

Comments
 (0)