]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgls: fix/update/restore the handling of --xattr and --cgroup-id
authorZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Thu, 16 Apr 2026 08:07:32 +0000 (10:07 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Thu, 16 Apr 2026 14:48:17 +0000 (16:48 +0200)
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.

man/systemd-cgls.xml
src/cgls/cgls.c

index 5280992c8c67cf49bd358a22e8aa122ea9e25aca..60cf6fa41aa2cb868d5ec4c8e0f259595ad17a5f 100644 (file)
       </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>
index 1c43543a90142ff89b38fdd62206fb79cbeb4d70..60d8e7701235ba94ce73b84f83dea4751dc90d1d 100644 (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)