From 57014dbab07f8cd68927cc9f7544cfc0d99706aa Mon Sep 17 00:00:00 2001 From: Curtis 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(-) (limited to 'bin/cash') 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