From: Mike Yuan Date: Thu, 23 Mar 2023 14:17:40 +0000 (+0800) Subject: journalctl: fix when --grep is used with --follow X-Git-Tag: v254-rc1~915 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c673fd52e048138a6786fb9114c1ddbf0057d6fb;p=thirdparty%2Fsystemd.git journalctl: fix when --grep is used with --follow Follow-up for #25147 (db4691961ca52759fe6645d0fddb659ee4299ac2) --follow sets arg_lines to 10, which breaks --grep as the latter implies --reverse. So let's not set --reverse if --follow is used. --- diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 69b40e68ea2..97e9c1aafc4 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1086,8 +1086,10 @@ static int parse_argv(int argc, char *argv[]) { return r; /* When --grep is used along with --lines, we don't know how many lines we can print. - * So we search backwards and count until enough lines have been printed or we hit the head. */ - if (arg_lines >= 0) + * So we search backwards and count until enough lines have been printed or we hit the head. + * An exception is that --follow might set arg_lines, so let's not imply --reverse + * if that is specified. */ + if (arg_lines >= 0 && !arg_follow) arg_reverse = true; }