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

Function sh_cd_target

src/pipeline/pass_shell.c:1287–1307  ·  view source on GitHub ↗

Where `cd v` lands: *out = AT an existing directory, else LOST. */

Source from the content-addressed store, hash-verified

1285
1286/* Where `cd v` lands: *out = AT an existing directory, else LOST. */
1287static const char *sh_cd_target(sh_t *s, const char *v, sh_cwd_t *out) {
1288 *out = (sh_cwd_t){SH_LOST, NULL};
1289 if (!v) {
1290 return NULL;
1291 }
1292 const char *c[PAIR_LEN] = {NULL, NULL};
1293 int n = sh_candidates(s, v, c);
1294 const char *hit = NULL;
1295 for (int i = 0; i < n; i++) {
1296 if (sh_dir_exists(s->ix, c[i])) {
1297 if (hit) {
1298 return NULL;
1299 }
1300 hit = c[i];
1301 }
1302 }
1303 if (hit) {
1304 *out = (sh_cwd_t){SH_AT, hit};
1305 }
1306 return hit;
1307}
1308
1309/* ── Deploy commands ───────────────────────────────────────────────── */
1310

Callers 2

sh_subst_cdFunction · 0.85
sh_chdirFunction · 0.85

Calls 2

sh_candidatesFunction · 0.85
sh_dir_existsFunction · 0.85

Tested by

no test coverage detected