summaryrefslogtreecommitdiffstats
path: root/tools/lvmcmdline.c
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2008-05-30 15:27:44 +0000
committerAlasdair Kergon <agk@redhat.com>2008-05-30 15:27:44 +0000
commitde24008109163ab401639ba4717ea397effd0eac (patch)
treee4b0a536d0fb6f438f5c1dc6ce70f03cc95aff5e /tools/lvmcmdline.c
parent0a5b690b708502acf7d92366dd5bff282d9ebe1a (diff)
downloadlvm2-de24008109163ab401639ba4717ea397effd0eac.tar.gz
lvm2-de24008109163ab401639ba4717ea397effd0eac.tar.xz
lvm2-de24008109163ab401639ba4717ea397effd0eac.zip
In script-processing mode, stop if any command fails.
Warn if command exits with non-zero status code without a prior log_error.
Diffstat (limited to 'tools/lvmcmdline.c')
-rw-r--r--tools/lvmcmdline.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index bb3fdaec..4ce2b031 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -875,6 +875,8 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
int ret = 0;
int locking_type;
+ init_error_message_produced(0);
+
/* each command should start out with sigint flag cleared */
sigint_clear();
@@ -1096,7 +1098,14 @@ static int _run_script(struct cmd_context *cmd, int argc, char **argv)
continue;
if (!strcmp(argv[0], "quit") || !strcmp(argv[0], "exit"))
break;
- lvm_run_command(cmd, argc, argv);
+ ret = lvm_run_command(cmd, argc, argv);
+ if (ret) {
+ if (!error_message_produced()) {
+ log_debug("Internal error: Failed command did not use log_error");
+ log_error("Command failed with status code %d.", ret);
+ }
+ break;
+ }
}
if (fclose(script))
@@ -1218,6 +1227,11 @@ int lvm2_main(int argc, char **argv, unsigned is_static)
if (ret == ENO_SUCH_CMD)
log_error("No such command. Try 'help'.");
+ if (ret && !error_message_produced()) {
+ log_debug("Internal error: Failed command did not use log_error");
+ log_error("Command failed with status code %d.", ret);
+ }
+
out:
lvm_fin(cmd);
if (ret == ECMD_PROCESSED)