All of lore.kernel.org
 help / color / mirror / Atom feed
From: adrian15 <adrian15sgd@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: pause and echo patch
Date: Sun, 17 Jun 2007 13:14:06 +0200	[thread overview]
Message-ID: <4675177E.3010304@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2313 bytes --]

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;
> +}
> +
>  \f
>  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



[-- Attachment #2: grub2_pause_and_echo.patch --]
[-- Type: text/x-patch, Size: 1685 bytes --]

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;
+}
+
 \f
 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


                 reply	other threads:[~2007-06-17 11:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4675177E.3010304@gmail.com \
    --to=adrian15sgd@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.