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

Function cliSplitArgs

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

Split the user provided command into multiple SDS arguments. * This function normally uses sdssplitargs() from sds.c which is able * to understand "quoted strings", escapes and so forth. However when * we are in Lua debugging mode and the "eval" command is used, we want * the remaining Lua script (after "e " or "eval ") to be passed verbatim * as a single big argument. */

Source from the content-addressed store, hash-verified

2094 * the remaining Lua script (after "e " or "eval ") to be passed verbatim
2095 * as a single big argument. */
2096static sds *cliSplitArgs(char *line, int *argc) {
2097 if (config.eval_ldb && (strstr(line,"eval ") == line ||
2098 strstr(line,"e ") == line))
2099 {
2100 sds *argv = sds_malloc(sizeof(sds)*2);
2101 *argc = 2;
2102 int len = strlen(line);
2103 int elen = line[1] == ' ' ? 2 : 5; /* "e " or "eval "? */
2104 argv[0] = sdsnewlen(line,elen-1);
2105 argv[1] = sdsnewlen(line+elen,len-elen);
2106 return argv;
2107 } else {
2108 return sdssplitargs(line,argc);
2109 }
2110}
2111
2112/* Set the CLI preferences. This function is invoked when an interactive
2113 * ":command" is called, or when reading ~/.redisclirc file, in order to

Callers 1

replFunction · 0.85

Calls 4

strstrFunction · 0.85
sds_mallocFunction · 0.85
sdsnewlenFunction · 0.85
sdssplitargsFunction · 0.85

Tested by

no test coverage detected