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
commit62213e443d8720845a1934e299fd651bef38190f (patch)
treeeca2100c98619ebe217c7d5ebf466b8753e93941 /bin
parentEnable warnings in libedit (diff)
downloadsrc-62213e443d8720845a1934e299fd651bef38190f.tar.gz
src-62213e443d8720845a1934e299fd651bef38190f.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);