Skip to content
Browse files

fixed prompt in redis cli when connecting to a socket; fixes issue #306

  • Loading branch information...
1 parent b362c11 commit 68aa79c175f1a8ad4e622a5e7afd7dd1a38a95ea @tchajed tchajed committed Jan 24, 2012
Showing with 12 additions and 6 deletions.
  1. +12 −6 src/redis-cli.c
View
18 src/redis-cli.c
@@ -91,12 +91,18 @@ 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);
- else
- snprintf(config.prompt,sizeof(config.prompt),"redis %s:%d[%d]> ",
- config.hostip, config.hostport, config.dbnum);
+ sds prompt = sdsnew("redis ");
+ if (config.hostsocket != NULL) {
+ prompt = sdscat(prompt, config.hostsocket);
+ } else {
+ prompt = sdscatprintf(prompt, "%s:%d", config.hostip, config.hostport);
+ if (config.dbnum > 0) {
+ prompt = sdscatprintf(prompt, "[%d]", config.dbnum);
+ }
+ }
+ prompt = sdscat(prompt, "> ");
+ strcpy(config.prompt, prompt);
+ //snprintf(config.prompt, sizeof(config.prompt), "redis ");
}
/*------------------------------------------------------------------------------

0 comments on commit 68aa79c

Please sign in to comment.
Something went wrong with that request. Please try again.