cd / pushd / popd; true when the command is one. */
| 2321 | |
| 2322 | /* cd / pushd / popd; true when the command is one. */ |
| 2323 | static 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. */ |
| 2347 | static const char *const SH_BUILD_VALUED[] = {"--build-arg", |
no test coverage detected