+2009-03-22 Yoshinori K. Okuji <okuji@enbug.org>
+
+ * normal/main.c (grub_normal_execute): Added an argument
+ BATCH to specify if an interactive interface should be provided
+ after reading a config file.
+ All callers updated.
+ (read_command_list): Prevent being executed twice.
+ (read_fs_list): Likewise.
+
+ * include/grub/normal.h (grub_normal_execute):
+
2009-03-22 Pavel Roskin <proski@gno.org>
* kern/powerpc/ieee1275/startup.S: Replace EXT_C(start) with
/* configfile.c - command to manually load config file */
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2005,2006,2007 Free Software Foundation, Inc.
+ * Copyright (C) 2005,2006,2007,2009 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
grub_env_context_open ();
}
- grub_normal_execute (args[0], 1);
+ grub_normal_execute (args[0], 1, ! new_env);
if (new_env)
grub_env_context_close ();
}
grub_err_t
-grub_normal_menu_addentry (int argc, const char **args, struct grub_script *script,
- const char *sourcecode)
+grub_normal_menu_addentry (int argc, const char **args,
+ struct grub_script *script, const char *sourcecode)
{
const char *menutitle = 0;
const char *menusourcecode;
classes_head->next = 0;
classes_tail = classes_head;
- menu = grub_env_get_data_slot("menu");
+ menu = grub_env_get_data_slot ("menu");
if (! menu)
return grub_error (GRUB_ERR_MENU, "no menu context");
{
/* Handle invalid argument. */
failed = 1;
- grub_error (GRUB_ERR_MENU, "invalid argument for menuentry: %s", args[i]);
+ grub_error (GRUB_ERR_MENU,
+ "invalid argument for menuentry: %s", args[i]);
break;
}
}
else
{
failed = 1;
- grub_error (GRUB_ERR_MENU, "too many titles for menuentry: %s", args[i]);
+ grub_error (GRUB_ERR_MENU,
+ "too many titles for menuentry: %s", args[i]);
break;
}
}
grub_enter_normal_mode (const char *config)
{
if (grub_setjmp (grub_exit_env) == 0)
- grub_normal_execute (config, 0);
+ grub_normal_execute (config, 0, 0);
}
/* Initialize the screen. */
read_command_list (void)
{
const char *prefix;
-
+ static int first_time = 1;
+
+ /* Make sure that this function does not get executed twice. */
+ if (! first_time)
+ return;
+ first_time = 0;
+
prefix = grub_env_get ("prefix");
if (prefix)
{
read_fs_list (void)
{
const char *prefix;
+ static int first_time = 1;
+
+ /* Make sure that this function does not get executed twice. */
+ if (! first_time)
+ return;
+ first_time = 0;
prefix = grub_env_get ("prefix");
if (prefix)
grub_fs_autoload_hook = autoload_fs_module;
}
-/* Read the config file CONFIG and execute the menu interface or
- the command-line interface. */
+/* Read the config file COFIG, and execute the menu interface or
+ the command-line interface if BATCH is false. */
void
-grub_normal_execute (const char *config, int nested)
+grub_normal_execute (const char *config, int nested, int batch)
{
grub_menu_t menu = 0;
grub_errno = GRUB_ERR_NONE;
}
- if (menu && menu->size)
+ if (! batch)
{
- grub_menu_viewer_show_menu (menu, nested);
- if (nested)
- free_menu (menu);
+ if (menu && menu->size)
+ {
+ grub_menu_viewer_show_menu (menu, nested);
+ if (nested)
+ free_menu (menu);
+ }
+ else
+ grub_cmdline_run (nested);
}
- else
- grub_cmdline_run (nested);
}
static grub_err_t