diff options
author | Csaba Henk <csaba@gluster.com> | 2010-09-15 08:11:17 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-16 23:07:38 -0700 |
commit | cecc24958374cfecddd64535c10d53ead8c7ad24 (patch) | |
tree | 7f9b3c00dbb0854b9f1de78bc2d0e0c76f720064 /cli/src/input.c | |
parent | d787bca47fc038facb34221ee9855934f7230ef4 (diff) |
cli: make cli behave nicely with batch commands piped in in stdin
Signed-off-by: Csaba Henk <csaba@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1570 (geosync related changes)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1570
Diffstat (limited to 'cli/src/input.c')
-rw-r--r-- | cli/src/input.c | 11 |
1 files changed, 9 insertions, 2 deletions
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); |