diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index b765926aad..2023e3bf28 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -991,11 +991,10 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) { if (!arg_follow) arg_journal_additional_open_flags = SD_JOURNAL_ASSUME_IMMUTABLE; - args = strv_copy(args); - if (!args) + r = strv_copy_unless_empty(args, remaining_args); + if (r < 0) return log_oom(); - *remaining_args = args; return 1; } diff --git a/test/units/TEST-04-JOURNAL.journal.sh b/test/units/TEST-04-JOURNAL.journal.sh index 403164016f..b24309a695 100755 --- a/test/units/TEST-04-JOURNAL.journal.sh +++ b/test/units/TEST-04-JOURNAL.journal.sh @@ -195,6 +195,9 @@ journalctl --fields journalctl --list-boots journalctl --update-catalog journalctl --list-catalog +[[ "$(journalctl --list-catalog | wc -l)" -gt 1 ]] +[[ "$(journalctl --list-catalog f77379a8490b408bbe5f6940505a777b | wc -l)" -eq 1 ]] +[[ "$(journalctl --dump-catalog | wc -l)" -gt "$(journalctl --dump-catalog f77379a8490b408bbe5f6940505a777b | wc -l)" ]] # Add new tests before here, the journald restarts below # may make tests flappy.