From df5341da9e452e50e22cccc22e9939d3afd36731 Mon Sep 17 00:00:00 2001 From: marco_g Date: Sun, 30 Apr 2006 20:29:51 +0000 Subject: [PATCH] 2006-04-30 Marco Gerards * normal/execute.c (grub_script_execute_cmd): Change the return type to `grub_err_t'. Correctly return the error. (grub_script_execute_cmdline): In case a command line is not a command or a function, try to interpret it as an assignment. --- ChangeLog | 7 +++++++ normal/execute.c | 24 ++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9af6dcb86..2d4d62559 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-04-30 Marco Gerards + + * normal/execute.c (grub_script_execute_cmd): Change the return + type to `grub_err_t'. Correctly return the error. + (grub_script_execute_cmdline): In case a command line is not a + command or a function, try to interpret it as an assignment. + 2006-04-30 Yoshinori K. Okuji * fs/hfsplus.c (grub_hfsplus_read_block): Fixed a memory leak. diff --git a/normal/execute.c b/normal/execute.c index fe28876ae..9f28bd3a6 100644 --- a/normal/execute.c +++ b/normal/execute.c @@ -25,14 +25,13 @@ #include #include -static int +static grub_err_t grub_script_execute_cmd (struct grub_script_cmd *cmd) { if (cmd == 0) return 0; - cmd->exec (cmd); - return 0; + return cmd->exec (cmd); } /* Parse ARG and return the textual representation. Add strings are @@ -104,7 +103,24 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) /* It's not a GRUB command, try all functions. */ func = grub_script_function_find (cmdline->cmdname); if (! func) - return 0; + { + /* As a last resort, try if it is an assignment. */ + char *assign = grub_strdup (cmdline->cmdname); + char *eq = grub_strchr (assign, '='); + + if (eq) + { + /* Create two strings and set the variable. */ + *eq = '\0'; + eq++; + grub_env_set (assign, eq); + + /* This was set because the command was not found. */ + grub_errno = GRUB_ERR_NONE; + } + grub_free (assign); + return 0; + } } if (cmdline->arglist)