From a57d9cc437ced3d3fd7fce64d1f698052651824d Mon Sep 17 00:00:00 2001
From: Bruno Deferrari <utizoc@gmail.com>
Date: Fri, 14 May 2010 11:04:01 -0300
Subject: [PATCH] If command is a shutdown, ignore errors on reply

---
 redis-cli.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/redis-cli.c b/redis-cli.c
index 98e9bdf16..863df9bf8 100644
--- a/redis-cli.c
+++ b/redis-cli.c
@@ -356,6 +356,7 @@ static int selectDb(int fd) {
 
 static int cliSendCommand(int argc, char **argv, int repeat) {
     struct redisCommand *rc = lookupCommand(argv[0]);
+    int shutdown = 0;
     int fd, j, retval = 0;
     sds cmd;
 
@@ -370,6 +371,8 @@ static int cliSendCommand(int argc, char **argv, int repeat) {
             fprintf(stderr,"Wrong number of arguments for '%s'\n",rc->name);
             return 1;
     }
+
+    if (!strcasecmp(rc->name,"shutdown")) shutdown = 1;
     if (!strcasecmp(rc->name,"monitor")) config.monitor_mode = 1;
     if (!strcasecmp(rc->name,"subscribe") ||
         !strcasecmp(rc->name,"psubscribe")) config.pubsub_mode = 1;
@@ -408,7 +411,7 @@ static int cliSendCommand(int argc, char **argv, int repeat) {
 
         retval = cliReadReply(fd);
         if (retval) {
-            return retval;
+            return shutdown ? 0 : retval;
         }
     }
     return 0;