Re: [hackers] [sbase] [PATCH 3/3] ed: Fix substitutions with non-determinate patterns

From: Wolfgang Corcoran-Mathe <wcm_AT_sigwinch.xyz>
Date: Mon, 25 Jul 2016 23:47:44 -0400

emg,

Quoth Evan Gates:
>On Sun, Jul 24, 2016 at 8:17 PM, Wolfgang Corcoran-Mathe
><wcm_AT_sigwinch.xyz> wrote:
>> Sorry, this last patch is simpleminded.
>>
>> Given the following text and substitution, what should happen?
>>
>> 'glorious'
>>
>> s/G*/P/g
>
>The sed behavior is based on other sed implementations. I think I
>based it on GNU sed and busybox sed test cases that make sure to
>increment the position in the string by one after each 0 length match.
>Whereas GNU has problems with consistency, I think sbase should not.

Right, and the same behavior is shown by all the seds I’ve seen (GNU,
BSD, Busybox & Plan 9). Interestingly, both GNU and BSD ed give an
error instead (for global substitution against a null-matching regex).

My guess is that the original (ed) behavior was to give an error—a
non-determinate pattern is almost always a mistake. sed, as a
non-interactive command, could not simply halt and had to “do
something reasonable with unreasonable input”. Thus, the
increment-and-try-again trick.

Someone with a greater knowledge of history could speak to the
accuracy of this. I do think it’s important that ed is an interactive
command, unlike sed.

Which behavior do you prefer?

Regards,

-- 
wcm
Received on Tue Jul 26 2016 - 05:47:44 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 26 2016 - 05:48:15 CEST