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

Function sh_eval_subst

src/pipeline/pass_shell.c:882–909  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

880}
881
882static 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
911static const char *sh_eval(sh_t *s, TSNode n) {
912 if (ts_node_is_null(n)) {

Callers 1

sh_evalFunction · 0.85

Calls 5

sh_typeFunction · 0.85
sh_is_pwdFunction · 0.85
sh_subst_cdFunction · 0.85
sh_unwrapFunction · 0.85
sh_eval_subst_commandFunction · 0.85

Tested by

no test coverage detected