mirror of
https://github.com/systemd/systemd.git
synced 2025-02-24 17:57:34 +03:00
systemctl: allow comma sepearted property lists
This commit is contained in:
parent
4a6022f01c
commit
033a842c36
@ -120,10 +120,9 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
<para>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
|
||||
<literal>MainPID</literal>. If specified more than once all
|
||||
properties with the specified names are
|
||||
shown.</para>
|
||||
properties with the specified names are shown.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@ -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;
|
||||
|
||||
if (!(l = strv_append(arg_property, optarg)))
|
||||
return -ENOMEM;
|
||||
FOREACH_WORD_SEPARATOR(word, size, source, ",", state) {
|
||||
char _cleanup_free_ *prop;
|
||||
char **tmp;
|
||||
|
||||
strv_free(arg_property);
|
||||
arg_property = l;
|
||||
prop = strndup(word, size);
|
||||
if (!prop)
|
||||
return -ENOMEM;
|
||||
|
||||
tmp = strv_append(arg_property, prop);
|
||||
if (!tmp)
|
||||
return -ENOMEM;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user