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

Function sh_chdir

src/pipeline/pass_shell.c:2323–2344  ·  view source on GitHub ↗

cd / pushd / popd; true when the command is one. */

Source from the content-addressed store, hash-verified

2321
2322/* cd / pushd / popd; true when the command is one. */
2323static bool sh_chdir(sh_t *s, const sh_argv_t *a) {
2324 const char *name = a->n > 0 ? a->v[0] : NULL;
2325 if (sh_eq(name, "popd")) {
2326 s->cwd = s->ndirs > 0 ? s->dirs[--s->ndirs] : (sh_cwd_t){SH_LOST, NULL};
2327 return true;
2328 }
2329 if (!sh_eq(name, "cd") && !sh_eq(name, "pushd")) {
2330 return false;
2331 }
2332 if (sh_eq(name, "pushd")) {
2333 if (sh_grow((void **)&s->dirs, &s->cap_dirs, s->ndirs, sizeof(*s->dirs))) {
2334 s->dirs[s->ndirs++] = s->cwd;
2335 }
2336 }
2337 const char *to = sh_first_operand(a, SKIP_ONE);
2338 sh_cwd_t next = {SH_LOST, NULL};
2339 if (to && strcmp(to, "-") != 0) {
2340 (void)sh_cd_target(s, to, &next);
2341 }
2342 s->cwd = next;
2343 return true;
2344}
2345
2346/* A container build's flags that take a separate value. */
2347static const char *const SH_BUILD_VALUED[] = {"--build-arg",

Callers 1

sh_commandFunction · 0.85

Calls 4

sh_eqFunction · 0.85
sh_growFunction · 0.85
sh_first_operandFunction · 0.85
sh_cd_targetFunction · 0.85

Tested by

no test coverage detected