The Open Group Base Specifications Issue 7, 2018 edition:
|    Substitute Command
|
|    Synopsis:
|
|        (.,.)s/RE/replacement/flags
[...]
|   A line can be split by substituting a <newline> into it. The
|   application shall ensure it escapes the <newline> in the replacement
|   by preceding it by <backslash>.
---
 ed.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ed.c b/ed.c
index b430e74..e2b2a6f 100644
--- a/ed.c
+++ b/ed.c
@@ -1049,8 +1049,11 @@ getrhs(int delim)
        static String s;
 
        string(&s);
-       while ((c = input()) != '\n' && c != EOF && c != delim)
+       while ((c = input()) != '\n' && c != EOF && c != delim) {
+               if (c == '\\' && (c = input()) != '\n')
+                       addchar('\\', &s);
                addchar(c, &s);
+       }
        addchar('\0', &s);
        if (c == EOF)
                error("invalid pattern delimiter");
-- 
2.43.0.rc0


Reply via email to