summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-04-25 11:57:56 +0200
committerLennart Poettering <lennart@poettering.net>2016-04-25 19:29:01 +0200
commit52051dd84c45c745ca877d8893be6f71aa27bf97 (patch)
tree07ba228dcaacf7fef197224cd62b193b5896db0a
parent2aab2fabbd1072f5cd1871e0046f49d13d4a4293 (diff)
journalctl: turn --unit= in combination with --user into --user-unit=
Let's be nice to users, and let's turn the nonsensical "--unit=… --user" into "--user-unit=…" which the user more likely meant. Fixes #1621
-rw-r--r--src/journal/journalctl.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index ae62170ae5..6de3489e12 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -873,6 +873,18 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
}
+ if (!strv_isempty(arg_system_units) && (arg_journal_type == SD_JOURNAL_CURRENT_USER)) {
+
+ /* Specifying --user and --unit= at the same time makes no sense (as the former excludes the user
+ * journal, but the latter excludes the system journal, thus resulting in empty output). Let's be nice
+ * to users, and automatically turn --unit= into --user-unit= if combined with --user. */
+ r = strv_extend_strv(&arg_user_units, arg_system_units, true);
+ if (r < 0)
+ return -ENOMEM;
+
+ arg_system_units = strv_free(arg_system_units);
+ }
+
return 1;
}