1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-13 12:58:20 +03:00

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.
This commit is contained in:
Mike Yuan 2023-03-23 22:17:40 +08:00 committed by Zbigniew Jędrzejewski-Szmek
parent 957b934f82
commit c673fd52e0

View 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;
}