diff options
author | dejun.xdj <dejun.xdj@alibaba-inc.com> | 2018-05-18 11:40:05 +0800 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2018-05-29 12:46:27 +0200 |
commit | 64bf60fb52406b20ef3dce3b94ed204d8e9f2fb0 (patch) | |
tree | 74faa03d7266b2467b4c78c08e2d2b0e09f74745 | |
parent | 5bed12aa0307a4b4969a0adebc1233db0b8607ac (diff) | |
download | redis-64bf60fb52406b20ef3dce3b94ed204d8e9f2fb0.tar.gz |
Detect and stop saving history for auth command with repeat option.
Put the repeat option checking code a little forward to avoid repeat logic.
-rw-r--r-- | src/redis-cli.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/redis-cli.c b/src/redis-cli.c index 681f0a718..f4a550094 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -1398,8 +1398,24 @@ static void repl(void) { cliRefreshPrompt(); while((line = linenoise(context ? config.prompt : "not connected> ")) != NULL) { if (line[0] != '\0') { + int repeat = 1, skipargs = 0; + char *endptr; + argv = cliSplitArgs(line,&argc); - if (strcasecmp(argv[0], "auth")) { + + /* check if we have a repeat command option and + * need to skip the first arg */ + if (argv && argc > 0) { + repeat = strtol(argv[0], &endptr, 10); + if (argc > 1 && *endptr == '\0' && repeat) { + skipargs = 1; + } else { + repeat = 1; + } + } + + /* Won't save auth command in history file */ + if (!(argv && argc > 0 && !strcasecmp(argv[0+skipargs], "auth"))) { if (history) linenoiseHistoryAdd(line); if (historyfile) linenoiseHistorySave(historyfile); } @@ -1434,15 +1450,6 @@ static void repl(void) { linenoiseClearScreen(); } else { long long start_time = mstime(), elapsed; - int repeat, skipargs = 0; - char *endptr; - - repeat = strtol(argv[0], &endptr, 10); - if (argc > 1 && *endptr == '\0' && repeat) { - skipargs = 1; - } else { - repeat = 1; - } issueCommandRepeat(argc-skipargs, argv+skipargs, repeat); |