pause and echo patch
I attach the proposal of patch and I comment some doubts that I have.
Quoted 6 lines
diff -urN
grub2_2007_05_31_original/commands/echo.cgrub2_2007_05_31_pause/commands/echo.ccommands/echo.c +0
-0@@ -110,16 +110,35 @@return 0 ; }
commands/echo.c line 121
Quoted 10 lines
commands/echo.c +9
-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!
Quoted 14 lines
commands/echo.c +9
-0+ 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,
commands/echo.c line 144
Quoted 10 lines
commands/echo.c +2
-1-"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?
conf/common.rmk line 174
Quoted 13 lines
diff -urN grub2_2007_05_31_original/conf/common.rmk grub2_2007_05_31_pause/conf/common.rmk
conf/common.rmk +1
-1@@ -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
commands/echo.c +20 -1
@@ -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" ); }
conf/common.rmk +1 -1
@@ -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