MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / cliSplitArgs

Function cliSplitArgs

src/redis-cli.c:1908–1922  ·  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

1906 * the remaining Lua script (after "e " or "eval ") to be passed verbatim
1907 * as a single big argument. */
1908static sds *cliSplitArgs(char *line, int *argc) {
1909 if (config.eval_ldb && (strstr(line,"eval ") == line ||
1910 strstr(line,"e ") == line))
1911 {
1912 sds *argv = sds_malloc(sizeof(sds)*2);
1913 *argc = 2;
1914 int len = strlen(line);
1915 int elen = line[1] == ' ' ? 2 : 5; /* "e " or "eval "? */
1916 argv[0] = sdsnewlen(line,elen-1);
1917 argv[1] = sdsnewlen(line+elen,len-elen);
1918 return argv;
1919 } else {
1920 return sdssplitargs(line,argc);
1921 }
1922}
1923
1924/* Set the CLI preferences. This function is invoked when an interactive
1925 * ":command" is called, or when reading ~/.redisclirc file, in order to

Callers 1

replFunction · 0.85

Calls 3

sds_mallocFunction · 0.85
sdsnewlenFunction · 0.85
sdssplitargsFunction · 0.85

Tested by

no test coverage detected