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: Vladimir 'φ-coder/phcoder' Serbinenko
Subject: Re: [PATCH] Reset grub_errno after embedding test on non-fatal failures
Date: Tue, 08 Nov 2011 15:36:24 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20111010 Iceowl/1.0b2 Icedove/3.1.15

On 27.09.2011 21:38, Seth Goldberg wrote:
> 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.
It's a good idea but I feel like the point where we restore original
setting is badly chosen. Consider:
for x in *; do
   echo $x;
done
You probably want to skip until the end of the script. I think it's
reasonable to restore the setting when user interaction is required.
This will have a neat effect of constraining the changes to term
subsystem. Since grub_getkey/grub_checkkey are in core changes to them
should be minimalised. They could just keep a counter how many times
they were called.
>
>
> --------------
> --- 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);
>
>
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/grub-devel
>


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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