From: Benno Schulenberg Date: Thu, 13 Mar 2025 14:51:49 +0000 (+0100) Subject: swapon: make options --help and --version override --summary X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad9b9058721a7322f702d5c9beea6e77cd923377;p=thirdparty%2Futil-linux.git swapon: make options --help and --version override --summary 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 --- diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c index 419155d67..f7f82bbfb 100644 --- a/sys-utils/swapon.c +++ b/sys-utils/swapon.c @@ -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 */