[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] Allow user-defined functions to override builtins. [take 2]
From: |
Glenn Washburn |
Subject: |
[PATCH 1/2] Allow user-defined functions to override builtins. [take 2] |
Date: |
Thu, 22 May 2014 01:44:12 -0500 |
Thanks for suggestions from Michel and Ben, I've added a pseudo-command
called "builtin" which will allow access to builtins that have been
overridden by functions.
Any help in getting this functionality committed would be much
appreciated.
---
grub-core/script/execute.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
index afd5513..857f8c6 100644
--- a/grub-core/script/execute.c
+++ b/grub-core/script/execute.c
@@ -941,14 +941,15 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
args = argv.args + 2;
cmdname = argv.args[1];
}
- grubcmd = grub_command_find (cmdname);
- if (! grubcmd)
+ /* Allow user functions to override built in commands. */
+ func = grub_script_function_find (cmdname);
+ if (! func)
{
grub_errno = GRUB_ERR_NONE;
- /* It's not a GRUB command, try all functions. */
- func = grub_script_function_find (cmdname);
- if (! func)
+ /* It's not a function, check if GRUB command. */
+ grubcmd = grub_command_find (cmdname);
+ if (! grubcmd)
{
/* As a last resort, try if it is an assignment. */
char *assign = grub_strdup (cmdname);
@@ -977,7 +978,9 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
}
/* Execute the GRUB command or function. */
- if (grubcmd)
+ if (func)
+ ret = grub_script_function_call (func, argc, args);
+ else
{
if (grub_extractor_level && !(grubcmd->flags
& GRUB_COMMAND_FLAG_EXTRACTOR))
@@ -990,8 +993,6 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
else
ret = (grubcmd->func) (grubcmd, argc, args);
}
- else
- ret = grub_script_function_call (func, argc, args);
if (invert)
{
--
1.8.3.2
- [PATCH 1/2] Allow user-defined functions to override builtins. [take 2],
Glenn Washburn <=