| 880 | } |
| 881 | |
| 882 | static const char *sh_eval_subst(sh_t *s, TSNode n) { |
| 883 | TSNode st[PAIR_LEN]; |
| 884 | int k = 0; |
| 885 | for (uint32_t i = 0; i < ts_node_named_child_count(n); i++) { |
| 886 | TSNode c = ts_node_named_child(n, i); |
| 887 | if (sh_type(c, "comment")) { |
| 888 | continue; |
| 889 | } |
| 890 | if (k == PAIR_LEN) { |
| 891 | return NULL; |
| 892 | } |
| 893 | st[k++] = c; |
| 894 | } |
| 895 | if (k == SKIP_ONE && sh_type(st[0], "list") && ts_node_named_child_count(st[0]) == PAIR_LEN) { |
| 896 | TSNode l = st[0]; |
| 897 | st[0] = ts_node_named_child(l, 0); |
| 898 | st[SKIP_ONE] = ts_node_named_child(l, SKIP_ONE); |
| 899 | k = PAIR_LEN; |
| 900 | } |
| 901 | if (k == PAIR_LEN) { |
| 902 | return sh_is_pwd(s, st[SKIP_ONE]) ? sh_subst_cd(s, st[0]) : NULL; |
| 903 | } |
| 904 | if (k == SKIP_ONE) { |
| 905 | TSNode c = sh_unwrap(st[0]); |
| 906 | return sh_type(c, "command") ? sh_eval_subst_command(s, c) : NULL; |
| 907 | } |
| 908 | return NULL; |
| 909 | } |
| 910 | |
| 911 | static const char *sh_eval(sh_t *s, TSNode n) { |
| 912 | if (ts_node_is_null(n)) { |
no test coverage detected