[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[microblaze-uclinux] [patch] disable successive double history entries in busybox shell



Hy everyone,

Before I ask my first question on this mailing list I want to contribute one patch that was very useful for me. It patches the busybox shell to NOT show successive double entries anymore.

Greetings,
Thomas.

Index: trunk/software/petalinux-dist/user/busybox/shell/cmdedit.c
===================================================================
--- trunk/software/petalinux-dist/user/busybox/shell/cmdedit.c (revision 2)
+++ trunk/software/petalinux-dist/user/busybox/shell/cmdedit.c (revision 53)
@@ -1127,9 +1127,10 @@
 static void get_previous_history(void)
 {
+    int ncur_history = cur_history;
 	if(command_ps[0] != 0 || history[cur_history] == 0) {
 		free(history[cur_history]);
 		history[cur_history] = bb_xstrdup(command_ps);
 	}
-	cur_history--;
+	while (--cur_history >= 0 && (strcmp(history[cur_history], history[ncur_history]) == 0)) {};
 }
 
@@ -1140,5 +1141,6 @@
 	if (ch < n_history) {
 		get_previous_history(); /* save the current history line */
-		return (cur_history = ch+1);
+        while (++cur_history < n_history && (strcmp(history[cur_history], history[ch]) == 0)) {};
+		return cur_history;
 	} else {
 		beep();


___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/