1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-02-08 05:57:26 +03:00

journalctl: Correctly handle combination of --reverse and --lines (fixes #1596)

(cherry picked from commit 23b392166388003530fef02ac5758c91315a707b)
(cherry picked from commit d8fd38769c36ef9b2e5e122c345bca05ef2be88f)
This commit is contained in:
Timo Schlüßler 2020-01-13 09:26:58 +00:00 committed by Zbigniew Jędrzejewski-Szmek
parent 0aa144ab1d
commit a592a40564

View File

@ -2429,15 +2429,6 @@ int main(int argc, char *argv[]) {
}
r = sd_journal_previous(j);
} 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_skip(j, arg_lines);
} else if (arg_reverse) {
r = sd_journal_seek_tail(j);
if (r < 0) {
@ -2447,6 +2438,15 @@ int main(int argc, char *argv[]) {
r = sd_journal_previous(j);
} 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_skip(j, arg_lines);
} else {
r = sd_journal_seek_head(j);
if (r < 0) {