|
From: | Antonio Diaz Diaz |
Subject: | Re: [Bug-ed] Global substitutions that insert newlines |
Date: | Mon, 15 Oct 2018 19:18:57 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 |
Hello Rob, Rob Arthan wrote:
I have a script that uses ed to generate C string definitions from nroff output. It makes essential use of global substitutions with a newline as the replacement text, e.g., g/^##*/s/#*/\ / This functionality is no longer available as of version 1.14 of GNU ed. Is there a work-around for this?
This functionality was removed from GNU ed because inside a global command the meaning of the escaped newline becomes ambiguous. The POSIX standard documents it:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ed.html"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>. Such substitution cannot be done as part of a g or v command list."
The workaround is to use 'sed' to split a line in this way. I think sed does not have this problem because it does not need a 'global' command.
Best regards, Antonio. --The right to self-determination is not conditional. All peoples have it, including the catalan people.
[Prev in Thread] | Current Thread | [Next in Thread] |