fabacb
From 594c1fec1644fdf291aa0ff23de20db65c4cfadf Mon Sep 17 00:00:00 2001
fabacb
From: David Teigland <teigland@redhat.com>
fabacb
Date: Wed, 17 Nov 2021 10:40:27 -0600
4d51e5
Subject: [PATCH 13/54] display: ignore --reportformat
fabacb
fabacb
Using the option would do nothing useful but would
fabacb
print extraneous braces.
fabacb
---
fabacb
 tools/command-lines.in | 12 ++++++------
fabacb
 tools/lvmcmdline.c     | 15 +++++++++++++++
fabacb
 2 files changed, 21 insertions(+), 6 deletions(-)
fabacb
fabacb
diff --git a/tools/command-lines.in b/tools/command-lines.in
fabacb
index 10b23e75d..00ac08934 100644
fabacb
--- a/tools/command-lines.in
fabacb
+++ b/tools/command-lines.in
fabacb
@@ -1359,10 +1359,10 @@ OO: --aligned, --all, --binary, --colon, --columns,
fabacb
 --configreport ConfigReport, --foreign, --history, --ignorelockingfailure,
fabacb
 --logonly, --maps, --noheadings,
fabacb
 --nosuffix, --options String, --sort String, --readonly,
fabacb
---reportformat ReportFmt, --segments, --select String, --separator String,
fabacb
+--segments, --select String, --separator String,
fabacb
 --shared, --unbuffered, --units Units
fabacb
 OP: VG|LV|Tag ...
fabacb
-IO: --partial, --ignoreskippedcluster
fabacb
+IO: --partial, --ignoreskippedcluster, --reportformat ReportFmt
fabacb
 ID: lvdisplay_general
fabacb
 
fabacb
 ---
fabacb
@@ -1590,10 +1590,10 @@ pvdisplay
fabacb
 OO: --aligned, --all, --binary, --colon, --columns, --configreport ConfigReport,
fabacb
 --foreign, --ignorelockingfailure,
fabacb
 --logonly, --maps, --noheadings, --nosuffix, --options String,
fabacb
---readonly, --reportformat ReportFmt, --select String, --separator String, --shared,
fabacb
+--readonly, --select String, --separator String, --shared,
fabacb
 --short, --sort String, --unbuffered, --units Units
fabacb
 OP: PV|Tag ...
fabacb
-IO: --ignoreskippedcluster
fabacb
+IO: --ignoreskippedcluster, --reportformat ReportFmt
fabacb
 ID: pvdisplay_general
fabacb
 
fabacb
 ---
fabacb
@@ -1809,10 +1809,10 @@ vgdisplay
fabacb
 OO: --activevolumegroups, --aligned, --binary, --colon, --columns,
fabacb
 --configreport ConfigReport, --foreign, --ignorelockingfailure,
fabacb
 --logonly, --noheadings, --nosuffix,
fabacb
---options String, --readonly, --reportformat ReportFmt, --select String,
fabacb
+--options String, --readonly, --select String,
fabacb
 --shared, --short, --separator String, --sort String, --unbuffered, --units Units
fabacb
 OP: VG|Tag ...
fabacb
-IO: --partial, --ignoreskippedcluster
fabacb
+IO: --partial, --ignoreskippedcluster, --reportformat ReportFmt
fabacb
 ID: vgdisplay_general
fabacb
 
fabacb
 ---
fabacb
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
fabacb
index 1e12bedca..1727ba089 100644
fabacb
--- a/tools/lvmcmdline.c
fabacb
+++ b/tools/lvmcmdline.c
fabacb
@@ -3058,6 +3058,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
fabacb
 	int i;
fabacb
 	int skip_hyphens;
fabacb
 	int refresh_done = 0;
fabacb
+	int io;
fabacb
 
fabacb
 	/* Avoid excessive access to /etc/localtime and set TZ variable for glibc
fabacb
 	 * so it does not need to check /etc/localtime everytime that needs that info */
fabacb
@@ -3140,6 +3141,20 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
fabacb
 	if (!(cmd->command = _find_command(cmd, cmd->name, &argc, argv)))
fabacb
 		return EINVALID_CMD_LINE;
fabacb
 
fabacb
+	/*
fabacb
+	 * If option --foo is set which is listed in IO (ignore option) in
fabacb
+	 * command-lines.in, then unset foo.  Commands won't usually use an
fabacb
+	 * ignored option, but there can be shared code that checks for --foo,
fabacb
+	 * and should not find it to be set.
fabacb
+	 */
fabacb
+	for (io = 0; io < cmd->command->io_count; io++) {
fabacb
+		int opt = cmd->command->ignore_opt_args[io].opt;
fabacb
+		if (arg_is_set(cmd, opt)) {
fabacb
+			log_debug("Ignore opt %d", opt);
fabacb
+			cmd->opt_arg_values[opt].count = 0;
fabacb
+		}
fabacb
+	}
fabacb
+
fabacb
 	/*
fabacb
 	 * Remaining position args after command name and --options are removed.
fabacb
 	 */
fabacb
-- 
4d51e5
2.34.3
fabacb