summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorCsaba Henk <csaba@redhat.com>2012-04-24 11:53:56 +0200
committerAnand Avati <avati@redhat.com>2012-06-01 16:49:39 -0700
commit2084c0e3d748b7e28d2fc9749ad9d1e2bf63208c (patch)
tree0137bf6ad134ed2d81aaa1c2c9fc3cc046b3d24e /cli/src
parent982be4925851e13b027c5dce59e7a92a76cb9aae (diff)
cli: let commands specify the exit value in batch mode
Old behavior: when cli is ran in batch mode (sequence of commands are fed to it in stdin), if a command returns an error (ie. -1), the cli exits upon it with 255 (-1 on 8 bit). New behavior: consider any non-zero return from cli commands as error and use the negative of that return value as exit value, thus giving control to cli commands over the exit value, while (as of the existing command set) adhering to the convention of exiting with 1 on error. Spotted upon stumbling upon mount/umount commands which did want to exit with 1 on error but that was not possible as of old behavior. Change-Id: I6f41191cdc718c3e676cfae1e404152f4cb715c5 BUG: 765214 Signed-off-by: Csaba Henk <csaba@redhat.com> Reviewed-on: http://review.gluster.com/3218 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-rpc-ops.c4
-rw-r--r--cli/src/input.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 2ab13261a9f..7cc85e48320 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -5741,7 +5741,7 @@ gf_cli3_1_mount_cbk (struct rpc_req *req, struct iovec *iov,
/* weird sounding but easy to parse... */
cli_err ("%d : failed with this errno (%s)",
rsp.op_errno, strerror (rsp.op_errno));
- ret = 1;
+ ret = -1;
}
out:
@@ -5805,7 +5805,7 @@ gf_cli3_1_umount_cbk (struct rpc_req *req, struct iovec *iov,
ret = 0;
else {
cli_err ("umount failed");
- ret = 1;
+ ret = -1;
}
out:
diff --git a/cli/src/input.c b/cli/src/input.c
index a88d358745a..004c9e300e5 100644
--- a/cli/src/input.c
+++ b/cli/src/input.c
@@ -71,11 +71,11 @@ 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)
+ if (ret != 0 && state->mode & GLUSTER_MODE_ERR_FATAL)
break;
}
- exit (ret);
+ exit (-ret);
return NULL;
}