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

Function sh_url_template

src/pipeline/pass_shell.c:2110–2130  ·  view source on GitHub ↗

An http(s) URL word the script states with a literal host but variable * parts after it ("https://host/releases/download/${VER}/x.tgz"), * from its source text as the shell reads the word -- up to an unquoted * blank or operator, as tree-sitter-bash may split an unquoted word with * expansions into several arguments: quotes dropped, each expansion of the * path a `{}` as in a Route path; then

Source from the content-addressed store, hash-verified

2108 * path a `{}` as in a Route path; then sh_url_norm. NULL when the host is
2109 * not literal. */
2110static const char *sh_url_template(sh_t *s, const sh_argv_t *a, int i) {
2111 sh_str_t out = {0};
2112 char quote = 0;
2113 for (const char *p = s->src + a->span[PAIR_LEN * i]; *p;) {
2114 if (!quote && (strchr(" \t\r\n|;&<>)", *p) || (*p == '\\' && p[SKIP_ONE] == '\n'))) {
2115 break;
2116 }
2117 if ((*p == '"' || *p == '\'') && (!quote || quote == *p)) {
2118 quote = quote ? 0 : *p;
2119 p++;
2120 } else if ((*p == '$' || *p == '`') && quote != '\'') {
2121 sh_str_add(s->a, &out, "{}", PAIR_LEN);
2122 p = sh_url_skip_expansion(p);
2123 } else {
2124 sh_str_add(s->a, &out, p, SKIP_ONE);
2125 p++;
2126 }
2127 }
2128 const char *raw = sh_str_done(&out);
2129 return raw ? sh_url_norm(s->a, raw) : NULL; /* a `{}` host is no literal one */
2130}
2131
2132static bool sh_ieq(const char *a, const char *b) {
2133 for (; *a && *b; a++, b++) {

Callers 1

sh_httpFunction · 0.85

Calls 4

sh_str_addFunction · 0.85
sh_url_skip_expansionFunction · 0.85
sh_str_doneFunction · 0.85
sh_url_normFunction · 0.85

Tested by

no test coverage detected