cgls: fix/update/restore the handling of --xattr and --cgroup-id

This is a bit tricky. Previously, the --help string said
"-x --xattr=BOOL", which normally means that '-x BOOL' and '--xattr BOOL'
and '--xattr=BOOL' are all accepted and equivalent. But actually only
the third form was accepted. '-x' should have been and is now documented
as "Same as --xattr=true". The man page tried to explain this, but not
very strongly. So update the man page to have more emphasis and restore
the special behaviour for -x and -c. This is a on old program, so I
think in this case, maintaining compatiblity in behaviour is important.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-04-16 16:48:17 +02:00
parent c108f84a0c
commit a60f12202f
2 changed files with 11 additions and 8 deletions
+5 -4
View File
@@ -114,22 +114,23 @@
</varlistentry>
<varlistentry>
<term><option>--xattr[=BOOL]</option></term>
<term><option>-x</option></term>
<term><option>--xattr=</option></term>
<listitem><para>Controls whether to include information about extended attributes of the listed
control groups in the output. With the long option, expects a boolean value. Defaults to no.
control groups in the output. With the long option only, optionally accepts a boolean value. Defaults
to no.
</para>
<xi:include href="version-info.xml" xpointer="v250"/></listitem>
</varlistentry>
<varlistentry>
<term><option>--cgroup-id[=BOOL]</option></term>
<term><option>-c</option></term>
<term><option>--cgroup-id=</option></term>
<listitem><para>Controls whether to include the numeric ID of the listed control groups in the
output. With the long option, expects a boolean value. Defaults to no.</para>
output. With the long option only, optionally accepts a boolean value. Defaults to no.</para>
<xi:include href="version-info.xml" xpointer="v250"/></listitem>
</varlistentry>
+6 -4
View File
@@ -112,8 +112,9 @@ static int parse_argv(int argc, char *argv[]) {
return log_oom();
break;
OPTION_FULL(OPTION_OPTIONAL_ARG, 'x', "xattr", "BOOL",
"Show cgroup extended attributes"):
OPTION_LONG_FLAGS(OPTION_OPTIONAL_ARG, "xattr", "BOOL",
"Show cgroup extended attributes"): {}
OPTION_SHORT('x', NULL, "Same as --xattr=true"):
if (arg) {
r = parse_boolean(arg);
if (r < 0)
@@ -124,8 +125,9 @@ static int parse_argv(int argc, char *argv[]) {
SET_FLAG(arg_output_flags, OUTPUT_CGROUP_XATTRS, r);
break;
OPTION_FULL(OPTION_OPTIONAL_ARG, 'c', "cgroup-id", "BOOL",
"Show cgroup ID"):
OPTION_LONG_FLAGS(OPTION_OPTIONAL_ARG, "cgroup-id", "BOOL",
"Show cgroup ID"): {}
OPTION_SHORT('c', NULL, "Same as --cgroup-id=true"):
if (arg) {
r = parse_boolean(arg);
if (r < 0)