diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h index 730aa3005..e1edbec15 100644 --- a/include/grub/script_sh.h +++ b/include/grub/script_sh.h @@ -73,15 +73,6 @@ struct grub_script_arglist int argcount; }; -/* Scope for grub script constructs. */ -struct grub_script_scope -{ - struct grub_script_scope *next; - - char **args; - unsigned int argc; -}; - /* A single command line. */ struct grub_script_cmdline { diff --git a/script/execute.c b/script/execute.c index 571b6785b..573dab4cb 100644 --- a/script/execute.c +++ b/script/execute.c @@ -30,6 +30,12 @@ is sizeof (int) * 3, and one extra for a possible -ve sign. */ #define ERRNO_DIGITS_MAX (sizeof (int) * 3 + 1) +/* Scope for grub script functions. */ +struct grub_script_scope +{ + char **args; + unsigned int argc; +}; static struct grub_script_scope *scope = 0; static char * @@ -242,15 +248,18 @@ grub_err_t grub_script_function_call (grub_script_function_t func, int argc, char **args) { grub_err_t ret = 0; + struct grub_script_scope *old_scope; struct grub_script_scope new_scope; new_scope.argc = argc; new_scope.args = args; - grub_list_push (GRUB_AS_LIST_P (&scope), GRUB_AS_LIST (&new_scope)); + + old_scope = scope; + scope = &new_scope; ret = grub_script_execute (func->func); - grub_list_pop (GRUB_AS_LIST_P (&scope)); + scope = old_scope; return ret; }