95 lines
3.0 KiB
Diff
95 lines
3.0 KiB
Diff
|
Based on 6c71341aeecc3d092ed90f66e1b2c481b8e260ff Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||
|
Date: Wed, 29 Oct 2014 22:46:30 -0400
|
||
|
Subject: [PATCH] systemctl: let list-{units,unit-files } honour --type
|
||
|
|
||
|
The docs don't clarify what is expected, but I don't see any reason
|
||
|
why --type should be ignored.
|
||
|
|
||
|
Also restucture the compund conditions into separate clauses for
|
||
|
easier reading.
|
||
|
---
|
||
|
src/systemctl/systemctl.c | 48 ++++++++++++++++++++++++++++++++++-----------
|
||
|
1 file changed, 37 insertions(+), 11 deletions(-)
|
||
|
|
||
|
--- src/systemctl/systemctl.c
|
||
|
+++ src/systemctl/systemctl.c 2014-11-18 00:00:00.000000000 +0000
|
||
|
@@ -305,21 +305,37 @@ static int compare_unit_info(const void
|
||
|
}
|
||
|
|
||
|
static bool output_show_unit(const UnitInfo *u, char **patterns) {
|
||
|
- const char *dot;
|
||
|
-
|
||
|
if (!strv_isempty(patterns)) {
|
||
|
char **pattern;
|
||
|
|
||
|
STRV_FOREACH(pattern, patterns)
|
||
|
if (fnmatch(*pattern, u->id, FNM_NOESCAPE) == 0)
|
||
|
- return true;
|
||
|
+ goto next;
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
- return (!arg_types || ((dot = strrchr(u->id, '.')) &&
|
||
|
- strv_find(arg_types, dot+1))) &&
|
||
|
- (arg_all || !(streq(u->active_state, "inactive")
|
||
|
- || u->following[0]) || u->job_id > 0);
|
||
|
+next:
|
||
|
+ if (arg_types) {
|
||
|
+ const char *dot;
|
||
|
+
|
||
|
+ dot = strrchr(u->id, '.');
|
||
|
+ if (!dot)
|
||
|
+ return false;
|
||
|
+
|
||
|
+ if (!strv_find(arg_types, dot+1))
|
||
|
+ return false;
|
||
|
+ }
|
||
|
+
|
||
|
+ if (arg_all)
|
||
|
+ return true;
|
||
|
+
|
||
|
+ if (u->job_id > 0)
|
||
|
+ return true;
|
||
|
+
|
||
|
+ if (streq(u->active_state, "inactive") || u->following[0])
|
||
|
+ return false;
|
||
|
+
|
||
|
+ return true;
|
||
|
}
|
||
|
|
||
|
static void output_units_list(const UnitInfo *unit_infos, unsigned c) {
|
||
|
@@ -1019,18 +1035,28 @@ static int compare_unit_file_list(const
|
||
|
}
|
||
|
|
||
|
static bool output_show_unit_file(const UnitFileList *u, char **patterns) {
|
||
|
- const char *dot;
|
||
|
-
|
||
|
if (!strv_isempty(patterns)) {
|
||
|
char **pattern;
|
||
|
|
||
|
STRV_FOREACH(pattern, patterns)
|
||
|
if (fnmatch(*pattern, basename(u->path), FNM_NOESCAPE) == 0)
|
||
|
- return true;
|
||
|
+ goto next;
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
- return !arg_types || ((dot = strrchr(u->path, '.')) && strv_find(arg_types, dot+1));
|
||
|
+next:
|
||
|
+ if (!strv_isempty(arg_types)) {
|
||
|
+ const char *dot;
|
||
|
+
|
||
|
+ dot = strrchr(u->path, '.');
|
||
|
+ if (!dot)
|
||
|
+ return false;
|
||
|
+
|
||
|
+ if (!strv_find(arg_types, dot+1))
|
||
|
+ return false;
|
||
|
+ }
|
||
|
+
|
||
|
+ return true;
|
||
|
}
|
||
|
|
||
|
static void output_unit_file_list(const UnitFileList *units, unsigned c) {
|