Jelajahi Sumber

autoscr: Fix one-character lines and non-newline terminated scripts

When not using hush, the autoscr command now executes lines that are
only one character long. It also runs the last line of scripts even if
it does not end in a newline.

Signed-off-by: Petri Lehtinen <petri.lehtinen@inoi.fi>
Petri Lehtinen 16 tahun lalu
induk
melakukan
3591293509
1 mengubah file dengan 3 tambahan dan 1 penghapusan
  1. 3 1
      common/cmd_autoscript.c

+ 3 - 1
common/cmd_autoscript.c

@@ -180,7 +180,7 @@ autoscript (ulong addr, const char *fit_uname)
 			if (*next == '\n') {
 			if (*next == '\n') {
 				*next = '\0';
 				*next = '\0';
 				/* run only non-empty commands */
 				/* run only non-empty commands */
-				if ((next - line) > 1) {
+				if (*line) {
 					debug ("** exec: \"%s\"\n",
 					debug ("** exec: \"%s\"\n",
 						line);
 						line);
 					if (run_command (line, 0) < 0) {
 					if (run_command (line, 0) < 0) {
@@ -192,6 +192,8 @@ autoscript (ulong addr, const char *fit_uname)
 			}
 			}
 			++next;
 			++next;
 		}
 		}
+		if (rcode == 0 && *line)
+			rcode = (run_command(line, 0) >= 0);
 	}
 	}
 #endif
 #endif
 	free (cmd);
 	free (cmd);