Unverified Commit 77d44bb7 authored by ikeberlein's avatar ikeberlein Committed by GitHub
Browse files

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.
parent 1df8c129
...@@ -1435,6 +1435,7 @@ static int cliSendCommand(int argc, char **argv, long repeat) { ...@@ -1435,6 +1435,7 @@ static int cliSendCommand(int argc, char **argv, long repeat) {
while (config.pubsub_mode) { while (config.pubsub_mode) {
if (cliReadReply(output_raw) != REDIS_OK) exit(1); if (cliReadReply(output_raw) != REDIS_OK) exit(1);
fflush(stdout); /* Make it grep friendly */
if (config.last_cmd_type == REDIS_REPLY_ERROR) { if (config.last_cmd_type == REDIS_REPLY_ERROR) {
if (config.push_output) { if (config.push_output) {
redisSetPushCallback(context, cliPushHandler); redisSetPushCallback(context, cliPushHandler);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment