mirror of
https://github.com/fluencelabs/redis
synced 2025-03-20 09:30:55 +00:00
Detect and stop saving history for auth command with repeat option.
Put the repeat option checking code a little forward to avoid repeat logic.
This commit is contained in:
parent
ef931ef93e
commit
c2e2314640
@ -1398,8 +1398,24 @@ static void repl(void) {
|
|||||||
cliRefreshPrompt();
|
cliRefreshPrompt();
|
||||||
while((line = linenoise(context ? config.prompt : "not connected> ")) != NULL) {
|
while((line = linenoise(context ? config.prompt : "not connected> ")) != NULL) {
|
||||||
if (line[0] != '\0') {
|
if (line[0] != '\0') {
|
||||||
|
int repeat = 1, skipargs = 0;
|
||||||
|
char *endptr;
|
||||||
|
|
||||||
argv = cliSplitArgs(line,&argc);
|
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 (history) linenoiseHistoryAdd(line);
|
||||||
if (historyfile) linenoiseHistorySave(historyfile);
|
if (historyfile) linenoiseHistorySave(historyfile);
|
||||||
}
|
}
|
||||||
@ -1434,15 +1450,6 @@ static void repl(void) {
|
|||||||
linenoiseClearScreen();
|
linenoiseClearScreen();
|
||||||
} else {
|
} else {
|
||||||
long long start_time = mstime(), elapsed;
|
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);
|
issueCommandRepeat(argc-skipargs, argv+skipargs, repeat);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user