+
+ /* If $FOO appears as single word, replace it by the split up variable */
+ if ((*i)[0] == '$') {
+ char *e = strv_env_get(env, *i+1);
+
+ if (e) {
+ char **w, **m;
+ unsigned q;
+
+ if (!(m = strv_split_quoted(e))) {
+ r[k] = NULL;
+ strv_free(r);
+ return NULL;
+ }
+
+ q = strv_length(m);
+ l = l + q - 1;
+
+ if (!(w = realloc(r, sizeof(char*) * (l+1)))) {
+ r[k] = NULL;
+ strv_free(r);
+ strv_free(m);
+ return NULL;
+ }
+
+ r = w;
+ memcpy(r + k, m, q * sizeof(char*));
+ free(m);
+
+ k += q;
+ continue;
+ }
+ }
+
+ /* If ${FOO} appears as part of a word, replace it by the variable as-is */