Where `cd v` lands: *out = AT an existing directory, else LOST. */
| 1285 | |
| 1286 | /* Where `cd v` lands: *out = AT an existing directory, else LOST. */ |
| 1287 | static 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 |
no test coverage detected