From 957b3a3e17cf695db9a05d9e030b1081e44eb6da Mon Sep 17 00:00:00 2001
From: marco_g <marco_g@localhost>
Date: Mon, 11 Dec 2006 21:00:06 +0000
Subject: [PATCH] 2006-12-11  Marco Gerards  <marco@gnu.org>

	* normal/menu_entry.c (run): Fix off by one bug so the last line
	is executed.  Move the loader check to outside the loop.
---
 ChangeLog           |  5 +++++
 normal/menu_entry.c | 10 +++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4bedee201..e74884d84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-11  Marco Gerards  <marco@gnu.org>
+
+	* normal/menu_entry.c (run): Fix off by one bug so the last line
+	is executed.  Move the loader check to outside the loop.
+
 2006-12-08  Hollis Blanchard  <hollis@penguinppc.org>
 
 	* kern/powerpc/ieee1275/cmain.c (cmain): Mark r3 and r4 as `UNUSED'.
diff --git a/normal/menu_entry.c b/normal/menu_entry.c
index 9bc6bba1e..a0597d36e 100644
--- a/normal/menu_entry.c
+++ b/normal/menu_entry.c
@@ -1007,7 +1007,7 @@ run (struct screen *screen)
 
 
   /* Execute the script, line for line.  */
-  while (currline < screen->num_lines - 1)
+  while (currline < screen->num_lines)
     {
       editor_getline (&nextline);
       parsed_script = grub_script_parse (nextline, editor_getline);
@@ -1018,15 +1018,15 @@ run (struct screen *screen)
 	  
 	  /* The parsed script was executed, throw it away.  */
 	  grub_script_free (parsed_script);
-
-	  if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ())
-	    /* Implicit execution of boot, only if something is loaded.  */
-	    grub_command_execute ("boot", 0);
 	}
       else
 	break;
     }
 
+  if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ())
+    /* Implicit execution of boot, only if something is loaded.  */
+    grub_command_execute ("boot", 0);
+
   if (grub_errno != GRUB_ERR_NONE)
     {
       grub_print_error ();