]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: fix when --grep is used with --follow
authorMike Yuan <me@yhndnzj.com>
Thu, 23 Mar 2023 14:17:40 +0000 (22:17 +0800)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 27 Mar 2023 08:28:59 +0000 (10:28 +0200)
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.

src/journal/journalctl.c

index 69b40e68ea2401a25d76bddb2383e08cedfd0a80..97e9c1aafc4a6522362a2b2cbc244611b1979d87 100644 (file)
@@ -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;
         }