[PATCH] swapon: make options --help and --version override --summary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 sys-utils/swapon.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

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 */
-- 
2.48.1





[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux