if (r < 0)
return r;
- if (argc <= 1) {
+ char **args = strv_skip(argv, 1);
+ if (args)
+ STRV_FOREACH(arg, args) {
+ int q;
+
+ if (arg != args)
+ puts("");
+
+ if (args[1]) {
+ pager_open(arg_pager_flags);
+ printf("Service %s%s%s:\n", ansi_highlight(), *arg, ansi_normal());
+ }
+
+ q = tree_one(bus, *arg);
+ if (q < 0 && r >= 0)
+ r = q;
+ }
+ else {
_cleanup_strv_free_ char **names = NULL;
- bool not_first = false;
r = sd_bus_list_names(bus, &names, NULL);
if (r < 0)
pager_open(arg_pager_flags);
- STRV_FOREACH(i, names) {
+ STRV_FOREACH(name, names) {
int q;
- if (!arg_unique && (*i)[0] == ':')
+ if (!arg_unique && (*name)[0] == ':')
continue;
- if (!arg_acquired && (*i)[0] == ':')
+ if (!arg_acquired && (*name)[0] == ':')
continue;
- if (not_first)
- printf("\n");
-
- printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal());
+ if (name != names)
+ puts("");
- q = tree_one(bus, *i);
- if (q < 0 && r >= 0)
- r = q;
-
- not_first = true;
- }
- } else
- STRV_FOREACH(i, strv_skip(argv, 1)) {
- int q;
+ printf("Service %s%s%s:\n", ansi_highlight(), *name, ansi_normal());
- if (i > argv+1)
- printf("\n");
-
- if (argv[2]) {
- pager_open(arg_pager_flags);
- printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal());
- }
-
- q = tree_one(bus, *i);
+ q = tree_one(bus, *name);
if (q < 0 && r >= 0)
r = q;
}
+ }
return r;
}