summaryrefslogtreecommitdiff
path: root/src/redis-cli.c
diff options
context:
space:
mode:
authorikeberlein <ikeberlein@yandex.ru>2021-06-08 11:34:38 +0300
committerGitHub <noreply@github.com>2021-06-08 11:34:38 +0300
commit77d44bb7b4f92a015aed231910d163f5571bf5f3 (patch)
tree54a2783ce6f9df604239a24411d59a3b8ef130b5 /src/redis-cli.c
parent1df8c129bc5a8ffaac28410dc1c39b4241c6078c (diff)
downloadredis-77d44bb7b4f92a015aed231910d163f5571bf5f3.tar.gz
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.
Diffstat (limited to 'src/redis-cli.c')
-rw-r--r--src/redis-cli.c1
1 files changed, 1 insertions, 0 deletions
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);