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

Function sh_loop

src/pipeline/pass_shell.c:2671–2693  ·  view source on GitHub ↗

A loop's body runs zero or more times, with its variable unknown. */

Source from the content-addressed store, hash-verified

2669
2670/* A loop's body runs zero or more times, with its variable unknown. */
2671static void sh_loop(sh_t *s, TSNode n) {
2672 for (uint32_t i = 0; i < ts_node_child_count(n); i++) {
2673 if (sh_eq(ts_node_field_name_for_child(n, i), "value")) {
2674 sh_walk_substs(s, ts_node_child(n, i)); /* for x in $(cmd) */
2675 }
2676 }
2677 sh_touch_t t = {0};
2678 sh_mark_t m = sh_mark(s);
2679 TSNode var = ts_node_child_by_field_name(n, TS_FIELD("variable"));
2680 if (!ts_node_is_null(var)) {
2681 sh_set(s, sh_text(s, var), &SH_UNKNOWN_VAL, false);
2682 }
2683 TSNode cond = ts_node_child_by_field_name(n, TS_FIELD("condition"));
2684 if (!ts_node_is_null(cond)) {
2685 sh_walk(s, cond);
2686 }
2687 TSNode body = ts_node_child_by_field_name(n, TS_FIELD("body"));
2688 if (!ts_node_is_null(body)) {
2689 sh_walk_children(s, body);
2690 }
2691 sh_clause_end(s, m, &t);
2692 sh_group_end(s, &t);
2693}
2694
2695/* A function body, read where it is defined: its locals stay inside; the
2696 * globals it sets and a directory it changes are unknown after it. */

Callers 1

sh_walkFunction · 0.85

Calls 9

sh_eqFunction · 0.85
sh_walk_substsFunction · 0.85
sh_markFunction · 0.85
sh_setFunction · 0.85
sh_textFunction · 0.85
sh_walkFunction · 0.85
sh_walk_childrenFunction · 0.85
sh_clause_endFunction · 0.85
sh_group_endFunction · 0.85

Tested by

no test coverage detected