summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--bin/cash/histedit.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/bin/cash/histedit.c b/bin/cash/histedit.c
index 92d8170a..d1e77f51 100644
--- a/bin/cash/histedit.c
+++ b/bin/cash/histedit.c
@@ -425,13 +425,14 @@ fc_replace(const char *s, char *p, char *r)
 
 	STARTSTACKSTR(dest);
 	while (*s) {
-		if (*s == *p && strncmp(s, p, plen) == 0) {
+		if (strncmp(s, p, plen) == 0) {
 			STPUTS(r, dest);
 			s += plen;
-			*p = '\0';	/* so no more matches */
-		} else
-			STPUTC(*s++, dest);
+			break;
+		}
+		STPUTC(*s++, dest);
 	}
+	STPUTS(s, dest);
 	STPUTC('\0', dest);
 	dest = grabstackstr(dest);