summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-01-14 15:17:23 -0500
committerJune McEnroe <june@causal.agency>2019-01-14 15:17:23 -0500
commit57014dbab07f8cd68927cc9f7544cfc0d99706aa (patch)
treea4e8a64313e78b6f6aa124b29e420ad2412d61c9 /bin
parentEnable warnings in libedit (diff)
downloadsrc-57014dbab07f8cd68927cc9f7544cfc0d99706aa.tar.gz
src-57014dbab07f8cd68927cc9f7544cfc0d99706aa.zip
Allow replacing empty string with fc old=new
Diffstat (limited to '')
-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);