MCPcopy Create free account
hub / github.com/F-Stack/f-stack / repl

Function repl

app/redis-6.2.6/src/redis-cli.c:2152–2289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2150}
2151
2152static void repl(void) {
2153 sds historyfile = NULL;
2154 int history = 0;
2155 char *line;
2156 int argc;
2157 sds *argv;
2158
2159 /* Initialize the help and, if possible, use the COMMAND command in order
2160 * to retrieve missing entries. */
2161 cliInitHelp();
2162 cliIntegrateHelp();
2163
2164 config.interactive = 1;
2165 linenoiseSetMultiLine(1);
2166 linenoiseSetCompletionCallback(completionCallback);
2167 linenoiseSetHintsCallback(hintsCallback);
2168 linenoiseSetFreeHintsCallback(freeHintsCallback);
2169
2170 /* Only use history and load the rc file when stdin is a tty. */
2171 if (isatty(fileno(stdin))) {
2172 historyfile = getDotfilePath(REDIS_CLI_HISTFILE_ENV,REDIS_CLI_HISTFILE_DEFAULT);
2173 //keep in-memory history always regardless if history file can be determined
2174 history = 1;
2175 if (historyfile != NULL) {
2176 linenoiseHistoryLoad(historyfile);
2177 }
2178 cliLoadPreferences();
2179 }
2180
2181 cliRefreshPrompt();
2182 while((line = linenoise(context ? config.prompt : "not connected> ")) != NULL) {
2183 if (line[0] != '\0') {
2184 long repeat = 1;
2185 int skipargs = 0;
2186 char *endptr = NULL;
2187
2188 argv = cliSplitArgs(line,&argc);
2189
2190 /* check if we have a repeat command option and
2191 * need to skip the first arg */
2192 if (argv && argc > 0) {
2193 errno = 0;
2194 repeat = strtol(argv[0], &endptr, 10);
2195 if (argc > 1 && *endptr == '\0') {
2196 if (errno == ERANGE || errno == EINVAL || repeat <= 0) {
2197 fputs("Invalid redis-cli repeat command option value.\n", stdout);
2198 sdsfreesplitres(argv, argc);
2199 linenoiseFree(line);
2200 continue;
2201 }
2202 skipargs = 1;
2203 } else {
2204 repeat = 1;
2205 }
2206 }
2207
2208 /* Won't save auth or acl setuser commands in history file */
2209 int dangerous = 0;

Callers 2

evalModeFunction · 0.85
mainFunction · 0.85

Calls 15

cliInitHelpFunction · 0.85
cliIntegrateHelpFunction · 0.85
linenoiseSetMultiLineFunction · 0.85
getDotfilePathFunction · 0.85
linenoiseHistoryLoadFunction · 0.85
cliLoadPreferencesFunction · 0.85
cliRefreshPromptFunction · 0.85
linenoiseFunction · 0.85
cliSplitArgsFunction · 0.85

Tested by

no test coverage detected