From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH] Reset grub_errno after embedding test on non-fatal failures
Date: Tue, 08 Nov 2011 15:36:24 +0100 [thread overview]
Message-ID: <4EB93E68.1080000@gmail.com> (raw)
In-Reply-To: <alpine.GSO.2.00.1109271236360.101470@oretfbsg>
[-- Attachment #1: Type: text/plain, Size: 3309 bytes --]
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
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]
next prev parent reply other threads:[~2011-11-08 14:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-26 20:27 [PATCH] Reset grub_errno after embedding test on non-fatal failures Mario Limonciello
2011-09-26 20:32 ` Vladimir 'φ-coder/phcoder' Serbinenko
2011-09-27 19:38 ` Seth Goldberg
2011-11-08 14:36 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2011-09-27 19:39 ` (Subject on previous email) Seth Goldberg
2011-09-28 21:45 ` Vladimir 'φ-coder/phcoder' Serbinenko
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=4EB93E68.1080000@gmail.com \
--to=phcoder@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).