Am Samstag, den 30.05.2009, 17:14 +0200 schrieb Vladimir 'phcoder'
Serbinenko:
> On Wed, May 27, 2009 at 2:16 PM, Felix Zielcke <fziel...@z-51.de> wrote:
> > Hi,
> >
> > here's a simple patch which adds a `true' and a `false' command.
> > `true' is actually needed by the compatibility code generated by
> > grub-mkconfig for the terminal.
> As far as I understand they are useful only in normal mode. Perhaps
> putting them into normal.mod or sh.mod would make more sense?

Ok here's a new patch which places them into normal.mod.
Does a `false' command actually make sense in grub?
-- 
Felix Zielcke
2009-06-01  Felix Zielcke  <fziel...@z-51.de>

        * normal/main.c (grub_cmd_true): New function.
        (grub_mini_cmd_false): Likewise.
        (cmd_true): New static variable.
        (cmd_false): Likewise.
        (GRUB_MOD_INIT(minicmd)): Register commands true and false.
        (GRUB_MOD_FINI(minicmd)): Unregister commands true and false.

diff --git a/normal/main.c b/normal/main.c
index 9c5a827..c08f3b9 100644
--- a/normal/main.c
+++ b/normal/main.c
@@ -536,6 +536,26 @@ grub_env_write_pager (struct grub_env_var *var 
__attribute__ ((unused)),
   return grub_strdup (val);
 }
 
+/* true */
+static grub_err_t
+grub_cmd_true (struct grub_command *cmd __attribute__ ((unused)),
+                   int argc __attribute__ ((unused)),
+                   char *argv[] __attribute__ ((unused)))
+{
+  return 0;
+}
+
+/* false */
+static grub_err_t
+grub_cmd_false (struct grub_command *cmd __attribute__ ((unused)),
+                   int argc __attribute__ ((unused)),
+                   char *argv[] __attribute__ ((unused)))
+{
+  return 1;
+}
+
+static grub_command_t cmd_true, cmd_false;
+
 GRUB_MOD_INIT(normal)
 {
   /* Normal mode shouldn't be unloaded.  */
@@ -561,6 +581,13 @@ GRUB_MOD_INIT(normal)
   /* Preserve hooks after context changes.  */
   grub_env_export ("color_normal");
   grub_env_export ("color_highlight");
+
+  cmd_true =
+    grub_register_command ("true", grub_cmd_true,
+                          0, "do nothing, successfully");
+  cmd_false =
+    grub_register_command ("false", grub_cmd_true,
+                          0, "do nothing, unsuccessfully");
 }
 
 GRUB_MOD_FINI(normal)
@@ -570,4 +597,6 @@ GRUB_MOD_FINI(normal)
   grub_register_variable_hook ("pager", 0, 0);
   grub_fs_autoload_hook = 0;
   free_handler_list ();
+  grub_unregister_command (cmd_true);
+  grub_unregister_command (cmd_false);
 }
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to