develooper Front page | perl.perl5.porters | Postings from August 2013

Re: [perl #119095] Empty regular expression does not match in some cases

Thread Previous | Thread Next
Aaron Crane
August 5, 2013 18:09
Re: [perl #119095] Empty regular expression does not match in some cases
Message ID:
Aristotle Pagaltzis <> wrote:
> A lot of the syntax and idioms lore that we think of as “regexps”, at
> least in a Unix-y tradition, is really the regexp vernacular of ed. The
> entire grep utility is an extraction of an ed idiom as a stand-alone
> program.
> And even when I say all this, I am almost certainly being ahistorical –
> I do not know in detail the lineage and history of ed and all its next
> of kin (ex/vi, grep, sed, patch etc) and would actually be surprised if
> the story weren’t more intertwined and complex than my portrayal, even
> WRT just this one aspect.
> (I expect Aaron to come up behind me and embarrass me now. :-) )

Nope, your summary pretty much covers it. :-)

ed(1) already exists in the First Edition manual (so before November
1971), but neither sed(1) nor grep(1) do:

grep(1) came next, in Fourth Edition (so between February and November 1973):

In 1975, George Coulouris at Queen Mary College (in London;
subsequently renamed Queen Mary and Westfield, and then Queen Mary,
University of London) wrote em ("editor for mortals"), an interactive
ed(1)-like editor for cursor-addressed displays.  When he visited
Berkeley in 1976, he took it with him, and a certain Bill Joy took it
and morphed it into ex(1), which shipped in 1BSD (March 1978):

vi(1) was originally (in 2BSD, May 1979) a hard link to ex(1); when it
was launched under that name, it would start in visual mode rather
than normal mode, but ex(1) had all the same abilities.

sed(1) didn't appear till Seventh Edition, in January 1979:

The original diff(1) appeared in Fifth Edition (June 1974), and
originally generated only "edit scripts" (à la modern `diff -e`) that
could be passed to ed(1):

As for patch(1), Larry first wrote it in 1984, and published it in
1985; it already handled context and unified diffs at that point, as
well as the traditional edit scripts:!topic/mod.sources/xSQM63e39YY

Now, Ken Thompson wrote the Unix ed(1) in PDP-11 assembler:

This means it can be dated to some time in 1971, according to Dennis Ritchie:

But it turns out we can rewind a little further.  A team at UCB
(including L. Peter Deutsch) wrote an editor called qed in 1968:

It's still possible to see the core of the ed(1) design in that, even
though the details differ quite a lot; for example, the 1968 qed
doesn't have regexes at all.

Ken Thompson ported qed to CTSS circa 1970, and therefore shortly
*before* he wrote ed(1); the manual for his port can be found here:

This is much more similar to the ed(1) we know and (presumably) love,
including regexes strictly more powerful than those in traditional
ed(1), and slashes to delimit them (where the 1968 qed used square
brackets for its search strings).  And we find that the manual says
"The null regular expression standing alone is equivalent to the last
regular expression encountered."

So this aspect of Perl can be dated back to code written no later than
1970, for a text editor running on an operating system that I suspect
noone subscribed to this list has ever used.


Aaron Crane **

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About