From 62213e443d8720845a1934e299fd651bef38190f Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Mon, 14 Jan 2019 15:17:23 -0500 Subject: Allow replacing empty string with fc old=new --- bin/cash/histedit.c | 9 +++++---- 1 file 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); -- cgit 1.4.1