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

Function sh_spawn_script

src/pipeline/pass_shell.c:1796–1821  ·  view source on GitHub ↗

The program is a script of the repository -- its path names a file of it, * or a shell runs one (bash [-opts] FILE; -c TEXT is no file) -- resolved to * exactly one file: that script is spawned. */

Source from the content-addressed store, hash-verified

1794 * or a shell runs one (bash [-opts] FILE; -c TEXT is no file) -- resolved to
1795 * exactly one file: that script is spawned. */
1796static void sh_spawn_script(sh_t *s, TSNode cmd, const sh_argv_t *a, int p) {
1797 const char *v = a->v[p];
1798 const char *path = NULL;
1799 if (sh_in(sh_basename(v), SH_SHELLS)) {
1800 int j = p + SKIP_ONE;
1801 while (j < a->n && a->v[j] && a->v[j][0] == '-' && !sh_eq(a->v[j], "-c")) {
1802 j++;
1803 }
1804 path = j < a->n && !sh_eq(a->v[j], "-c") ? a->v[j] : NULL;
1805 } else if (strchr(v, '/') && !strpbrk(v, "*?[")) {
1806 path = v;
1807 }
1808 if (!path) {
1809 return;
1810 }
1811 int64_t id = 0;
1812 const char *hit = sh_unique_file(s, path, &id);
1813 if (hit) {
1814 sh_hit_push(s, cmd,
1815 (sh_hit_t){.via = s->exec ? "exec" : "shell",
1816 .tgt = id,
1817 .ext = sh_basename(hit),
1818 .path = hit,
1819 .spawn = true});
1820 }
1821}
1822
1823/* ── make TARGET (P3.5b) ───────────────────────────────────────────── */
1824

Callers 1

sh_spawnFunction · 0.85

Calls 5

sh_inFunction · 0.85
sh_basenameFunction · 0.85
sh_eqFunction · 0.85
sh_unique_fileFunction · 0.85
sh_hit_pushFunction · 0.85

Tested by

no test coverage detected