summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2016-05-20 14:23:43 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2016-06-02 14:38:14 +0200
commit3f373d367257e4ec7819653b748dab832dcc9ad2 (patch)
treeccfe3d800abe0954c102a0f8ace331d30d2d3016
parent25879f03b87ff1f44e4ec71cea44d9290b61dfe2 (diff)
downloadlvm2-3f373d367257e4ec7819653b748dab832dcc9ad2.tar.gz
refactor: move 'interactive' field from struct command_line to struct cmd_context as 'is_interactive' switch
-rw-r--r--lib/commands/toolcontext.h1
-rw-r--r--tools/lvm.c3
-rw-r--r--tools/lvm2cmdline.h1
-rw-r--r--tools/lvmcmdline.c2
4 files changed, 4 insertions, 3 deletions
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 2cecf2751..3c7785a39 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -113,6 +113,7 @@ struct cmd_context {
* Switches.
*/
unsigned is_long_lived:1; /* optimises persistent_filter handling */
+ unsigned is_interactive:1;
unsigned check_pv_dev_sizes:1;
unsigned handles_missing_pvs:1;
unsigned handles_unknown_segments:1;
diff --git a/tools/lvm.c b/tools/lvm.c
index b7cec819c..18e349068 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -193,7 +193,7 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline)
_cmdline = cmdline;
- _cmdline->interactive = 1;
+ cmd->is_interactive = 1;
while (1) {
free(input);
input = readline("lvm> ");
@@ -246,6 +246,7 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline)
}
_write_history();
}
+ cmd->is_interactive = 0;
free(input);
return 0;
diff --git a/tools/lvm2cmdline.h b/tools/lvm2cmdline.h
index 3b68af731..80bd03ea1 100644
--- a/tools/lvm2cmdline.h
+++ b/tools/lvm2cmdline.h
@@ -23,7 +23,6 @@ struct cmdline_context {
struct command *commands;
int num_commands;
int commands_size;
- int interactive;
};
int lvm2_main(int argc, char **argv);
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index be6821b78..b43365125 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1730,7 +1730,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
stack;
}
- if (ret == EINVALID_CMD_LINE && !_cmdline.interactive)
+ if (ret == EINVALID_CMD_LINE && !cmd->is_interactive)
_short_usage(cmd->command->name);
log_debug("Completed: %s", cmd->cmd_line);