From 77d44bb7b4f92a015aed231910d163f5571bf5f3 Mon Sep 17 00:00:00 2001 From: ikeberlein Date: Tue, 8 Jun 2021 11:34:38 +0300 Subject: [PATCH] Make redis-cli grep friendly in pubsub mode (#9013) redis-cli is grep friendly for all commands but SUBSCRIBE/PSUBSCRIBE. it is unable to process output from these commands line by line piped to another program because of output buffering. to overcome this situation I propose to flush stdout each time when it is written with reply from these commands the same way it is already done for all other commands. --- src/redis-cli.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/redis-cli.c b/src/redis-cli.c index d0e7daaef..39535a9e0 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -1435,6 +1435,7 @@ static int cliSendCommand(int argc, char **argv, long repeat) { while (config.pubsub_mode) { if (cliReadReply(output_raw) != REDIS_OK) exit(1); + fflush(stdout); /* Make it grep friendly */ if (config.last_cmd_type == REDIS_REPLY_ERROR) { if (config.push_output) { redisSetPushCallback(context, cliPushHandler);