--- ed.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/ed.c b/ed.c index 16fbe04..60673a2 100644 --- a/ed.c +++ b/ed.c @@ -1061,13 +1061,21 @@ execsh(void) } while ((c = input()) != '\0') { - if (c == '%' && (cmd.siz == 0 || cmd.str[cmd.siz - 1] != '\\')) { + switch (c) { + case '%': if (savfname[0] == '\0') error("no current filename"); repl = 1; for (p = savfname; *p; ++p) addchar(*p, &cmd); - } else { + break; + case '\\': + c = input(); + if (c != '%') { + back(c); + c = '\\'; + } + default: addchar(c, &cmd); } } -- 2.37.3