commit 890f6c2c050149e63efe5b385b104c8383342973
parent aacfa18b79f459b8419f424079d50fc5bc263791
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 27 Nov 2023 09:21:45 +0100
ed: Improve execsh
Diffstat:
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/ed.c b/ed.c
@@ -1067,13 +1067,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);
}
}