diff --git a/common/cmd_autoscript.c b/common/cmd_autoscript.c
index c2e7e665aadd992a0b8023abb6c3c9fb7674a919..0439da2cd3befd4481cbfcf5001243335f74bf3e 100644
--- a/common/cmd_autoscript.c
+++ b/common/cmd_autoscript.c
@@ -180,7 +180,7 @@ autoscript (ulong addr, const char *fit_uname)
 			if (*next == '\n') {
 				*next = '\0';
 				/* run only non-empty commands */
-				if ((next - line) > 1) {
+				if (*line) {
 					debug ("** exec: \"%s\"\n",
 						line);
 					if (run_command (line, 0) < 0) {
@@ -192,6 +192,8 @@ autoscript (ulong addr, const char *fit_uname)
 			}
 			++next;
 		}
+		if (rcode == 0 && *line)
+			rcode = (run_command(line, 0) >= 0);
 	}
 #endif
 	free (cmd);