+static int show(sd_bus *bus, char **args) {
+ bool show_properties, show_status, new_line = false;
+ bool ellipsized = false;
+ int r, ret = 0;
+
+ assert(bus);
+ assert(args);
+
+ show_properties = streq(args[0], "show");
+ show_status = streq(args[0], "status");
+
+ if (show_properties)
+ pager_open_if_enabled();
+
+ /* If no argument is specified inspect the manager itself */
+
+ if (show_properties && strv_length(args) <= 1)
+ return show_one(args[0], bus, "/org/freedesktop/systemd1", show_properties, &new_line, &ellipsized);
+
+ if (show_status && strv_length(args) <= 1) {
+
+ pager_open_if_enabled();
+ show_system_status(bus);
+ new_line = true;
+
+ if (arg_all)
+ ret = show_all(args[0], bus, false, &new_line, &ellipsized);
+ } else {
+ _cleanup_free_ char **patterns = NULL;
+ char **name;
+
+ STRV_FOREACH(name, args + 1) {
+ _cleanup_free_ char *unit = NULL;
+ uint32_t id;
+
+ if (safe_atou32(*name, &id) < 0) {
+ if (strv_push(&patterns, *name) < 0)
+ return log_oom();
+
+ continue;
+ } else if (show_properties) {
+ /* Interpret as job id */
+ if (asprintf(&unit, "/org/freedesktop/systemd1/job/%u", id) < 0)
+ return log_oom();
+
+ } else {
+ /* Interpret as PID */
+ r = get_unit_dbus_path_by_pid(bus, id, &unit);
+ if (r < 0) {
+ ret = r;
+ continue;
+ }
+ }
+
+ r = show_one(args[0], bus, unit, show_properties,
+ &new_line, &ellipsized);
+ if (r < 0)
+ return r;
+ else if (r > 0 && ret == 0)
+ ret = r;
+ }
+
+ if (!strv_isempty(patterns)) {
+ _cleanup_strv_free_ char **names = NULL;
+
+ r = expand_names(bus, patterns, NULL, &names);
+ if (r < 0)
+ log_error("Failed to expand names: %s", strerror(-r));
+
+ STRV_FOREACH(name, names) {
+ _cleanup_free_ char *unit;
+
+ unit = unit_dbus_path_from_name(*name);
+ if (!unit)
+ return log_oom();
+
+ r = show_one(args[0], bus, unit, show_properties,
+ &new_line, &ellipsized);
+ if (r < 0)
+ return r;
+ else if (r > 0 && ret == 0)
+ ret = r;
+ }
+ }
+ }
+
+ if (ellipsized && !arg_quiet)
+ printf("Hint: Some lines were ellipsized, use -l to show in full.\n");
+
+ return ret;
+}
+