]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
swapon: make options --help and --version override --summary
authorBenno Schulenberg <bensberg@telfort.nl>
Thu, 13 Mar 2025 14:51:49 +0000 (15:51 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 17 Mar 2025 09:51:32 +0000 (10:51 +0100)
When -h or --help is among the given options, most utilities
print a help text, ignoring all other options and arguments.
Make `swapon --summary --help` conform to this general pattern.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
sys-utils/swapon.c

index 419155d67394bff887689801c4263f1d1d0043bf..f7f82bbfb9d5856320b46d2359b6bb089a7fc1f3 100644 (file)
@@ -145,6 +145,7 @@ struct swapon_ctl {
                no_heading,             /* toggle --show headers */
                raw,                    /* toggle --show alignment */
                show,                   /* display --show information */
+               summarize,              /* display summary of swap use */
                verbose;                /* be chatty */
 };
 
@@ -965,8 +966,8 @@ int main(int argc, char *argv[])
                        ctl.fix_page_size = 1;
                        break;
                case 's':               /* status report */
-                       status = display_summary();
-                       return status;
+                       ctl.summarize = 1;
+                       break;
                case 'v':               /* be chatty */
                        ctl.verbose = 1;
                        break;
@@ -1007,6 +1008,11 @@ int main(int argc, char *argv[])
        }
        argv += optind;
 
+       if (ctl.summarize) {
+               status = display_summary();
+               return status;
+       }
+
        if (ctl.show || (!ctl.all && !numof_labels() && !numof_uuids() && *argv == NULL)) {
                if (!ctl.ncolumns) {
                        /* default columns */