grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Reset grub_errno after embedding test on non-fatal failures


From: Seth Goldberg
Subject: Re: [PATCH] Reset grub_errno after embedding test on non-fatal failures
Date: Tue, 27 Sep 2011 12:38:36 -0700 (PDT)
User-agent: Alpine 2.00 (GSO 1167 2008-08-23)

Hi,

I finally got fed up with having no 'c' to continue when pager was set to 1. This may be a bit hackish, so I'm bracing for the flame ;), but it's here if it'll help someone else.


--------------
--- grub-core/normal/term.c     2011-04-10 11:56:23 +0000
+++ grub-core/normal/term.c     2011-09-27 19:33:34 +0000
@@ -40,7 +40,7 @@
 static struct term_state *term_states = NULL;

 /* If the more pager is active.  */
-static int grub_more;
+int grub_more, real_grub_more;

 static void
 putcode_real (grub_uint32_t code, struct grub_term_output *term);
@@ -60,11 +60,11 @@
   grub_uint16_t *pos;
   grub_term_output_t term;
   grub_uint32_t *unicode_str, *unicode_last_position;
+  const char *PROMPT_STRING = "--MORE-- ('c' to disable paging for the remainder of 
this command)";

   pos = grub_term_save_pos ();

-  grub_utf8_to_ucs4_alloc ("--MORE--", &unicode_str,
-                          &unicode_last_position);
+  grub_utf8_to_ucs4_alloc (PROMPT_STRING, &unicode_str, 
&unicode_last_position);

   if (!unicode_str)
     {
@@ -87,7 +87,7 @@
   /* Remove the message.  */
   grub_term_restore_pos (pos);
   FOR_ACTIVE_TERM_OUTPUTS(term)
-    grub_print_spaces (term, 8);
+    grub_print_spaces (term, grub_strlen(PROMPT_STRING));
   grub_term_restore_pos (pos);
   grub_free (pos);

@@ -99,6 +99,11 @@
       for (state = term_states; state; state = state->next)
        state->num_lines--;
     }
+  else if (key == 'c' || key == 'C')
+    {
+      grub_more = 0;
+      grub_normal_reset_more ();
+    }
   else
     grub_normal_reset_more ();
 }
@@ -107,9 +112,10 @@
 grub_set_more (int onoff)
 {
   if (onoff == 1)
-    grub_more++;
-  else
-    grub_more--;
+    real_grub_more++;
+  else if (real_grub_more > 0)
+    real_grub_more--;
+  grub_more = real_grub_more;
   grub_normal_reset_more ();
 }


=== modified file 'grub-core/script/execute.c'
--- grub-core/script/execute.c  2010-12-02 09:31:06 +0000
+++ grub-core/script/execute.c  2011-09-27 19:25:12 +0000
@@ -445,11 +445,13 @@
 {
   int ret;
   char errnobuf[ERRNO_DIGITS_MAX + 1];
+  extern int grub_more, real_grub_more;

   if (cmd == 0)
     return 0;

   ret = cmd->exec (cmd);
+  grub_more = real_grub_more;

   grub_snprintf (errnobuf, sizeof (errnobuf), "%d", ret);
   grub_env_set ("?", errnobuf);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]