[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-ed] Global substitutions that insert newlines

From: Rob Arthan
Subject: Re: [Bug-ed] Global substitutions that insert newlines
Date: Mon, 15 Oct 2018 18:32:07 -0400
User-agent: SquirrelMail/1.5.2 [SVN]


Thanks. I did indeed completely rewrite my ed script as a sed script.

This is an annoying side-effect of the POSIX standardisation: some
implementations of ed allowed the terminating character to be dropped from
a substitution command (i.e., they allowed "s/<pattern>/<text>" as well as
"s/<pattern>/<text>/").  This introduced an "ambiguity" (in the POSIX
description and not, as far as I know, in any implementation) that
eventually caused a useful feature to be dropped from POSIX. A better
solution in the POSiX standard would have been either always to require
the terminating character (as the ed implementations I grew up with did)
or to legislate in favour of the newline interpretation if the terminator
was omitted in the ambiguous cases (which is what the GNU implementation
originally did).

Thanks again for your time and effort on supporting ed and for your
response to my report. It's a shame that the upshot is that I have had to
replace my ed script by a much less clear sed script.



Antonio Diaz Diaz wrote:
> 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.
> _______________________________________________
> bug-ed mailing list address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-ed

reply via email to

[Prev in Thread] Current Thread [Next in Thread]