* grub-core/normal/menu_entry.c (run): Execute commands from menu

editor under argument scope.
	Reported by: Jordan Uggla
This commit is contained in:
BVK Chaitanya 2010-12-19 09:55:51 +05:30
commit 30aff4cb3a
2 changed files with 34 additions and 31 deletions

View file

@ -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

View file

@ -1163,36 +1163,34 @@ 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;
source = grub_malloc (size + 1);
if (! source)
return NULL;
size = 0;
for (i = 0; i < screen->num_lines; i++)
{ {
*line = 0; grub_strcpy (source + size, screen->lines[i].buf);
return 0; size += screen->lines[i].len;
source[size++] = '\n';
} }
source[size] = '\0';
/* Trim down space characters. */ return source;
for (p = linep->buf + linep->len - 1;
p >= linep->buf && grub_isspace (*p);
p--)
;
*++p = '\0';
linep->len = p - linep->buf;
for (p = linep->buf; grub_isspace (*p); p++)
;
*line = grub_strdup (p);
currline++;
return 0;
} }
grub_cls (); grub_cls ();
@ -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 ();