I attach the proposal of patch and I comment some doubts that I have.

diff -urN grub2_2007_05_31_original/commands/echo.c 
grub2_2007_05_31_pause/commands/echo.c
--- grub2_2007_05_31_original/commands/echo.c   2007-06-11 11:53:26.000000000 
+0200
+++ grub2_2007_05_31_pause/commands/echo.c      2007-06-17 04:25:26.000000000 
+0200
@@ -110,16 +110,35 @@
   return 0;
 }
+static grub_err_t
+grub_cmd_pause (struct grub_arg_list *state __attribute__ ((unused)),
+             int argc, char **args)
+
+{
+
+  char key;
+ if (argc!=0) + grub_cmd_echo(state,argc,args);
Here there is the trick for not duplicating code!
+  key = grub_getkey ();
+ + return 0;
+}
+
 
 GRUB_MOD_INIT(echo)
 {
+
+  (void) mod;                  /* To stop warning. */
+  grub_register_command ("pause", grub_cmd_pause, GRUB_COMMAND_FLAG_BOTH,
+                        "pause [-e|-n] [MESSAGE]", "Pause and optionally show a 
message with echo command.", options);
   (void) mod;                  /* To stop warning. */
   grub_register_command ("echo", grub_cmd_echo, GRUB_COMMAND_FLAG_BOTH,
-                        "echo [-e|-n] FILE", "Display a line of text.",
+                        "echo [-e|-n] \"STRING\"", "Display a line of text.",
                         options);
 }
GRUB_MOD_FINI(echo)
 {
   grub_unregister_command ("echo");
+  grub_unregister_command ("pause");
 }
I do not understand very well what's a module.
For instance should I have loaded the echo and pause commands in a
different module?

diff -urN grub2_2007_05_31_original/conf/common.rmk 
grub2_2007_05_31_pause/conf/common.rmk
--- grub2_2007_05_31_original/conf/common.rmk   2007-06-11 11:53:27.000000000 
+0200
+++ grub2_2007_05_31_pause/conf/common.rmk      2007-06-17 04:18:07.000000000 
+0200
@@ -168,7 +168,7 @@
 pkgdata_MODULES += hello.mod boot.mod terminal.mod ls.mod      \
        cmp.mod cat.mod help.mod font.mod search.mod            \
        loopback.mod configfile.mod                             \
-       terminfo.mod test.mod blocklist.mod
+       terminfo.mod test.mod blocklist.mod echo.mod
# For hello.mod.
 hello_mod_SOURCES = hello/hello.c

So if I needed to edit this rmk in order to have one more module I
should replicate the lines where it is read echo.mod and put pause.mod,
but I should not change the lines with echo.c to pause.c because both
commands are in the same file...

        Am I right?


adrian15


diff -urN grub2_2007_05_31_original/commands/echo.c grub2_2007_05_31_pause/commands/echo.c
--- grub2_2007_05_31_original/commands/echo.c	2007-06-11 11:53:26.000000000 +0200
+++ grub2_2007_05_31_pause/commands/echo.c	2007-06-17 04:25:26.000000000 +0200
@@ -110,16 +110,35 @@
   return 0;
 }
 
+static grub_err_t
+grub_cmd_pause (struct grub_arg_list *state __attribute__ ((unused)),
+	      int argc, char **args)
+
+{
+
+  char key;
+  if (argc!=0) 
+    grub_cmd_echo(state,argc,args);
+  key = grub_getkey ();
+  
+  return 0;
+}
+
 
 GRUB_MOD_INIT(echo)
 {
+
+  (void) mod;			/* To stop warning. */
+  grub_register_command ("pause", grub_cmd_pause, GRUB_COMMAND_FLAG_BOTH,
+			 "pause [-e|-n] [MESSAGE]", "Pause and optionally show a message with echo command.", options);
   (void) mod;			/* To stop warning. */
   grub_register_command ("echo", grub_cmd_echo, GRUB_COMMAND_FLAG_BOTH,
-			 "echo [-e|-n] FILE", "Display a line of text.",
+			 "echo [-e|-n] \"STRING\"", "Display a line of text.",
 			 options);
 }
 
 GRUB_MOD_FINI(echo)
 {
   grub_unregister_command ("echo");
+  grub_unregister_command ("pause");
 }

diff -urN grub2_2007_05_31_original/conf/common.rmk grub2_2007_05_31_pause/conf/common.rmk
--- grub2_2007_05_31_original/conf/common.rmk	2007-06-11 11:53:27.000000000 +0200
+++ grub2_2007_05_31_pause/conf/common.rmk	2007-06-17 04:18:07.000000000 +0200
@@ -168,7 +168,7 @@
 pkgdata_MODULES += hello.mod boot.mod terminal.mod ls.mod	\
 	cmp.mod cat.mod help.mod font.mod search.mod		\
 	loopback.mod configfile.mod				\
-	terminfo.mod test.mod blocklist.mod
+	terminfo.mod test.mod blocklist.mod echo.mod
 
 # For hello.mod.
 hello_mod_SOURCES = hello/hello.c

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to