From 033a842c36e7629f81d05d12a4ed8c298ad4d3f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 16 Feb 2013 17:20:28 -0500 Subject: [PATCH] systemctl: allow comma sepearted property lists --- man/systemctl.xml | 5 ++--- src/systemctl/systemctl.c | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/man/systemctl.xml b/man/systemctl.xml index 1a55522b1..683f2e740 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -120,10 +120,9 @@ along with systemd; If not, see . When showing unit/job/manager properties, limit display to certain properties as specified as argument. If not specified all set properties are shown. The argument - should be a property name, such as + should be a comma-seperated list of property names, such as MainPID. If specified more than once all - properties with the specified names are - shown. + properties with the specified names are shown. diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index ddf46b66d..509651c1f 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -4394,18 +4394,33 @@ static int systemctl_parse_argv(int argc, char *argv[]) { log_info("Use -t help to see a list of allowed values."); return -EINVAL; case 'p': { - char **l; + char *word, *state; + size_t size; + /* Make sure that if the empty property list + was specified, we won't show any properties. */ + const char *source = isempty(optarg) ? " " : optarg; + + FOREACH_WORD_SEPARATOR(word, size, source, ",", state) { + char _cleanup_free_ *prop; + char **tmp; + + prop = strndup(word, size); + if (!prop) + return -ENOMEM; - if (!(l = strv_append(arg_property, optarg))) - return -ENOMEM; + tmp = strv_append(arg_property, prop); + if (!tmp) + return -ENOMEM; - strv_free(arg_property); - arg_property = l; + strv_free(arg_property); + arg_property = tmp; + } /* If the user asked for a particular * property, show it to him, even if it is * empty. */ arg_all = true; + break; } -- 2.30.2