Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Fix for issue redis#306, thanks to tchajed (on github) for the pull r…
Browse files Browse the repository at this point in the history
…equest. The original patch was reworked a bit.
  • Loading branch information
antirez committed Feb 22, 2012
1 parent a8a3275 commit b805430
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/redis-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static struct config {
char *auth;
int raw_output; /* output mode per command */
sds mb_delim;
char prompt[32];
char prompt[128];
} config;

static void usage();
Expand All @@ -88,12 +88,19 @@ static long long mstime(void) {
}

static void cliRefreshPrompt(void) {
if (config.dbnum == 0)
snprintf(config.prompt,sizeof(config.prompt),"redis %s:%d> ",
config.hostip, config.hostport);
int len;

if (config.hostsocket != NULL)
len = snprintf(config.prompt,sizeof(config.prompt),"redis %s",
config.hostsocket);
else
snprintf(config.prompt,sizeof(config.prompt),"redis %s:%d[%d]> ",
config.hostip, config.hostport, config.dbnum);
len = snprintf(config.prompt,sizeof(config.prompt),"redis %s:%d",
config.hostip, config.hostport);
/* Add [dbnum] if needed */
if (config.dbnum != 0)
len += snprintf(config.prompt+len,sizeof(config.prompt)-len,"[%d]",
config.dbnum);
snprintf(config.prompt+len,sizeof(config.prompt)-len,"> ");
}

/*------------------------------------------------------------------------------
Expand Down

0 comments on commit b805430

Please sign in to comment.