From: Timo Schlüßler Date: Mon, 13 Jan 2020 09:26:58 +0000 (+0000) Subject: journalctl: Correctly handle combination of --reverse and --lines (fixes #1596) X-Git-Tag: v245-rc1~142 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=23b392166388003530fef02ac5758c91315a707b;p=thirdparty%2Fsystemd.git journalctl: Correctly handle combination of --reverse and --lines (fixes #1596) --- diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index c0916f372f3..17565abe212 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -2428,23 +2428,23 @@ int main(int argc, char *argv[]) { } r = sd_journal_previous(j); - } else if (arg_lines >= 0) { + } else if (arg_reverse) { r = sd_journal_seek_tail(j); if (r < 0) { log_error_errno(r, "Failed to seek to tail: %m"); goto finish; } - r = sd_journal_previous_skip(j, arg_lines); + r = sd_journal_previous(j); - } else if (arg_reverse) { + } else if (arg_lines >= 0) { r = sd_journal_seek_tail(j); if (r < 0) { log_error_errno(r, "Failed to seek to tail: %m"); goto finish; } - r = sd_journal_previous(j); + r = sd_journal_previous_skip(j, arg_lines); } else { r = sd_journal_seek_head(j);