- struct grub2_word *word;
-
- list_for_each_entry(&argv->words, word, argv_list) {
- if (!word->expand)
- continue;
-
- expand_word(script, word);
+ struct grub2_word *top_word, *word;
+
+ list_for_each_entry(&argv->words, top_word, argv_list) {
+ /* expand vars and squash the list of words into the top struct.
+ * todo: splitting
+ */
+ for (word = top_word; word; word = word->next) {
+ if (word->type == GRUB2_WORD_VAR)
+ expand_var(script, word);
+
+ if (word == top_word)
+ continue;
+
+ top_word->text = talloc_asprintf_append(top_word->text,
+ "%s", word->text);
+ }
+ top_word->next = NULL;