A loop's body runs zero or more times, with its variable unknown. */
| 2669 | |
| 2670 | /* A loop's body runs zero or more times, with its variable unknown. */ |
| 2671 | static 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. */ |
no test coverage detected