From 4e6029435111adcad71489aca2dd68bc65aeffd4 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sat, 19 Jul 2014 21:05:07 -0400 Subject: journalctl,man: allow + only between terms https://bugzilla.redhat.com/show_bug.cgi?id=1110712 --- src/journal/journalctl.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/journal/journalctl.c') diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 92e8286334..7aedbf0c57 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -699,15 +699,20 @@ static int generate_new_id128(void) { static int add_matches(sd_journal *j, char **args) { char **i; + bool have_term = false; assert(j); STRV_FOREACH(i, args) { int r; - if (streq(*i, "+")) + if (streq(*i, "+")) { + if (!have_term) + break; r = sd_journal_add_disjunction(j); - else if (path_is_absolute(*i)) { + have_term = false; + + } else if (path_is_absolute(*i)) { _cleanup_free_ char *p, *t = NULL, *t2 = NULL; const char *path; _cleanup_free_ char *interpreter = NULL; @@ -756,8 +761,12 @@ static int add_matches(sd_journal *j, char **args) { r = sd_journal_add_match(j, t, 0); if (t2) r = sd_journal_add_match(j, t2, 0); - } else + have_term = true; + + } else { r = sd_journal_add_match(j, *i, 0); + have_term = true; + } if (r < 0) { log_error("Failed to add match '%s': %s", *i, strerror(-r)); @@ -765,6 +774,11 @@ static int add_matches(sd_journal *j, char **args) { } } + if (!strv_isempty(args) && !have_term) { + log_error("\"+\" can only be used between terms"); + return -EINVAL; + } + return 0; } -- cgit v1.2.3-54-g00ecf