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.
This commit is contained in:
ikeberlein 2021-06-08 11:34:38 +03:00 committed by GitHub
parent 1df8c129bc
commit 77d44bb7b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);