summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli.h3
-rw-r--r--cli/src/input.c11
2 files changed, 11 insertions, 3 deletions
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 091114fcaca..44f65368521 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -39,7 +39,8 @@ enum argp_option_keys {
ARGP_PORT_KEY = 'p',
};
-#define GLUSTER_MODE_SCRIPT (1 << 0)
+#define GLUSTER_MODE_SCRIPT (1 << 0)
+#define GLUSTER_MODE_ERR_FATAL (1 << 1)
struct cli_state;
struct cli_cmd_word;
diff --git a/cli/src/input.c b/cli/src/input.c
index 7c3e78b16ca..5c38efe13e7 100644
--- a/cli/src/input.c
+++ b/cli/src/input.c
@@ -71,6 +71,8 @@ cli_input (void *d)
if (len > 0 && cmd[len - 1] == '\n') //strip trailing \n
cmd[len - 1] = '\0';
ret = cli_cmd_process_line (state, cmd);
+ if (ret == -1 && state->mode & GLUSTER_MODE_ERR_FATAL)
+ break;
}
exit (ret);
@@ -89,9 +91,14 @@ cli_input_init (struct cli_state *state)
return ret;
}
- state->prompt = "gluster> ";
+ if (isatty (STDIN_FILENO)) {
+ state->prompt = "gluster> ";
- cli_rl_enable (state);
+ cli_rl_enable (state);
+ } else {
+ state->prompt = "";
+ state->mode = GLUSTER_MODE_SCRIPT | GLUSTER_MODE_ERR_FATAL;
+ }
if (!state->rl_enabled)
ret = pthread_create (&state->input, NULL, cli_input, state);