MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / sh_program

Function sh_program

src/pipeline/pass_shell.c:1380–1398  ·  view source on GitHub ↗

The index of the program argv runs, past wrappers (time, sudo, retry N, * timeout D, env A=B, ...); -1 when argv has none. Its value may be unknown * (NULL). */

Source from the content-addressed store, hash-verified

1378 * timeout D, env A=B, ...); -1 when argv has none. Its value may be unknown
1379 * (NULL). */
1380static int sh_program(const sh_t *s, const sh_argv_t *a) {
1381 static const char *const wrappers[] = {"time", "sudo", "exec", "nice", "nohup",
1382 "command", "env", "timeout", "retry", NULL};
1383 int i = 0;
1384 while (i < a->n) {
1385 if (!a->v[i] || !sh_in(sh_basename(a->v[i]), wrappers)) {
1386 return i;
1387 }
1388 if (strcmp(a->v[i], "command") == 0 && i + SKIP_ONE < a->n &&
1389 (sh_eq(a->v[i + SKIP_ONE], "-v") || sh_eq(a->v[i + SKIP_ONE], "-V"))) {
1390 return -1; /* command -v X: is there an X, not a run of it */
1391 }
1392 i++;
1393 while (i < a->n && sh_wrapper_arg(s, a, i)) {
1394 i++;
1395 }
1396 }
1397 return -1;
1398}
1399
1400/* kubectl's options that take a separate value (before the verb). */
1401static const char *const SH_KUBECTL_VALUED[] = {"-n",

Callers 5

sh_findFunction · 0.85
sh_deploy_commandFunction · 0.85
sh_spawnFunction · 0.85
sh_httpFunction · 0.85
sh_buildFunction · 0.85

Calls 4

sh_inFunction · 0.85
sh_basenameFunction · 0.85
sh_eqFunction · 0.85
sh_wrapper_argFunction · 0.85

Tested by

no test coverage detected