"${name[@]}" / ${name[*]} as a whole word: the array, NULL when not. */
| 971 | |
| 972 | /* "${name[@]}" / ${name[*]} as a whole word: the array, NULL when not. */ |
| 973 | static const sh_val_t *sh_array_word(sh_t *s, TSNode w) { |
| 974 | if (sh_type(w, "string") && ts_node_named_child_count(w) == SKIP_ONE) { |
| 975 | w = ts_node_named_child(w, 0); |
| 976 | } |
| 977 | if (!sh_type(w, "expansion") || ts_node_named_child_count(w) != SKIP_ONE) { |
| 978 | return NULL; |
| 979 | } |
| 980 | TSNode sub = ts_node_named_child(w, 0); |
| 981 | if (!sh_type(sub, "subscript")) { |
| 982 | return NULL; |
| 983 | } |
| 984 | TSNode base = ts_node_child_by_field_name(sub, TS_FIELD("name")); |
| 985 | TSNode idx = ts_node_child_by_field_name(sub, TS_FIELD("index")); |
| 986 | const char *it = ts_node_is_null(idx) ? NULL : sh_text(s, idx); |
| 987 | if (ts_node_is_null(base) || !it || (strcmp(it, "@") != 0 && strcmp(it, "*") != 0)) { |
| 988 | return NULL; |
| 989 | } |
| 990 | bool found = false; |
| 991 | const sh_val_t *v = sh_lookup(s, sh_text(s, base), &found); |
| 992 | return v; |
| 993 | } |
| 994 | |
| 995 | /* An unquoted expansion may split into several words. */ |
| 996 | static bool sh_may_split(TSNode w) { |
no test coverage detected