* grub-core/normal/menu_entry.c (run): Execute commands from menu
editor under argument scope. Reported by: Jordan Uggla
This commit is contained in:
commit
30aff4cb3a
2 changed files with 34 additions and 31 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2010-12-19 BVK Chaitanya <bvk.groups@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/normal/menu_entry.c (run): Execute commands from menu
|
||||||
|
editor under argument scope.
|
||||||
|
Reported by: Jordan Uggla
|
||||||
|
|
||||||
2010-12-18 Colin Watson <cjwatson@ubuntu.com>
|
2010-12-18 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
* grub-core/normal/term.c (print_more): Make \r or \n scroll one
|
* grub-core/normal/term.c (print_more): Make \r or \n scroll one
|
||||||
|
|
|
@ -1163,37 +1163,35 @@ clear_completions_all (struct screen *screen)
|
||||||
static int
|
static int
|
||||||
run (struct screen *screen)
|
run (struct screen *screen)
|
||||||
{
|
{
|
||||||
int currline = 0;
|
char *script;
|
||||||
char *nextline;
|
|
||||||
int errs_before;
|
int errs_before;
|
||||||
grub_menu_t menu;
|
grub_menu_t menu;
|
||||||
|
char *dummy[1] = { NULL };
|
||||||
|
|
||||||
auto grub_err_t editor_getline (char **line, int cont);
|
auto char * editor_getsource (void);
|
||||||
grub_err_t editor_getline (char **line, int cont __attribute__ ((unused)))
|
char * editor_getsource (void)
|
||||||
{
|
{
|
||||||
struct line *linep = screen->lines + currline;
|
int i;
|
||||||
char *p;
|
int size = 0;
|
||||||
|
char *source;
|
||||||
|
|
||||||
if (currline > screen->num_lines)
|
for (i = 0; i < screen->num_lines; i++)
|
||||||
{
|
size += screen->lines[i].len + 1;
|
||||||
*line = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Trim down space characters. */
|
source = grub_malloc (size + 1);
|
||||||
for (p = linep->buf + linep->len - 1;
|
if (! source)
|
||||||
p >= linep->buf && grub_isspace (*p);
|
return NULL;
|
||||||
p--)
|
|
||||||
;
|
|
||||||
*++p = '\0';
|
|
||||||
|
|
||||||
linep->len = p - linep->buf;
|
size = 0;
|
||||||
for (p = linep->buf; grub_isspace (*p); p++)
|
for (i = 0; i < screen->num_lines; i++)
|
||||||
;
|
{
|
||||||
*line = grub_strdup (p);
|
grub_strcpy (source + size, screen->lines[i].buf);
|
||||||
currline++;
|
size += screen->lines[i].len;
|
||||||
return 0;
|
source[size++] = '\n';
|
||||||
}
|
}
|
||||||
|
source[size] = '\0';
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
grub_cls ();
|
grub_cls ();
|
||||||
grub_printf (" ");
|
grub_printf (" ");
|
||||||
|
@ -1212,12 +1210,11 @@ run (struct screen *screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Execute the script, line for line. */
|
/* Execute the script, line for line. */
|
||||||
while (currline < screen->num_lines)
|
script = editor_getsource ();
|
||||||
{
|
if (! script)
|
||||||
editor_getline (&nextline, 0);
|
return 0;
|
||||||
if (grub_normal_parse_line (nextline, editor_getline))
|
grub_script_execute_sourcecode (script, 0, dummy);
|
||||||
break;
|
grub_free (script);
|
||||||
}
|
|
||||||
|
|
||||||
if (errs_before != grub_err_printed_errors)
|
if (errs_before != grub_err_printed_errors)
|
||||||
grub_wait_after_message ();
|
grub_wait_after_message ();
|
||||||
|
|
Loading…
Reference in a new issue