local / declare / typeset / export / readonly NAME[=VALUE] ... */
| 2304 | |
| 2305 | /* local / declare / typeset / export / readonly NAME[=VALUE] ... */ |
| 2306 | static void sh_declare(sh_t *s, TSNode n) { |
| 2307 | TSNode kw = ts_node_child(n, 0); |
| 2308 | const char *k = ts_node_is_null(kw) ? "" : ts_node_type(kw); |
| 2309 | bool local = strcmp(k, "local") == 0 || |
| 2310 | (s->in_func && (strcmp(k, "declare") == 0 || strcmp(k, "typeset") == 0)); |
| 2311 | bool declares = local || strcmp(k, "declare") == 0 || strcmp(k, "typeset") == 0; |
| 2312 | for (uint32_t i = 0; i < ts_node_named_child_count(n); i++) { |
| 2313 | TSNode c = ts_node_named_child(n, i); |
| 2314 | if (sh_type(c, "variable_assignment")) { |
| 2315 | sh_assign(s, c, local); |
| 2316 | } else if (declares && sh_type(c, "variable_name")) { |
| 2317 | sh_set(s, sh_text(s, c), &SH_UNKNOWN_VAL, local); |
| 2318 | } |
| 2319 | } |
| 2320 | } |
| 2321 | |
| 2322 | /* cd / pushd / popd; true when the command is one. */ |
| 2323 | static bool sh_chdir(sh_t *s, const sh_argv_t *a) { |