On Mon, May 19, 2014 at 3:38 AM, Michel Hermier <michel.herm...@gmail.com>wrote:
> Le 19/05/2014 08:37, Glenn Washburn a écrit : > > Currently, builtin commands take precedence over user-defined >> functions. This patch reverses that precedence, so that users can >> "override" builtin commands. Builtin commands may be accessed by >> issuing the command prefixed by an '@' character. >> > If you want to go this way, I would have preferred a 'builtin' command > like other shell do, instead of reinventing the wheel and invent a new > syntax. > But this only my opinion as a user, wait for developers opinion. > > Seconded, particularly as the @ syntax is used elsewhere as echo suppression. there is no need to confuse people. > >> My motivation for this change is to hook insmod in loaded configfiles >> which set $prefix to a different location than desired. If there are >> any changes needed to help get this functionality included, please let >> me know. >> >> Glenn >> >> --- >> 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..0769151 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[0] == >> '@')?(cmdname+1):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) >> { >> > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel > -- -- Ben Hildred Automation Support Services 303 815 6721
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel