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

Function sh_declare

src/pipeline/pass_shell.c:2306–2320  ·  view source on GitHub ↗

local / declare / typeset / export / readonly NAME[=VALUE] ... */

Source from the content-addressed store, hash-verified

2304
2305/* local / declare / typeset / export / readonly NAME[=VALUE] ... */
2306static 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. */
2323static bool sh_chdir(sh_t *s, const sh_argv_t *a) {

Callers 1

sh_walkFunction · 0.85

Calls 4

sh_typeFunction · 0.85
sh_assignFunction · 0.85
sh_setFunction · 0.85
sh_textFunction · 0.85

Tested by

no test coverage detected