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
| 2108 | * path a `{}` as in a Route path; then sh_url_norm. NULL when the host is |
| 2109 | * not literal. */ |
| 2110 | static 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 | |
| 2132 | static bool sh_ieq(const char *a, const char *b) { |
| 2133 | for (; *a && *b; a++, b++) { |
no test coverage detected