The video chat between David Brailsford and Brian Kernighan has sparked a lot of interest and commentary among the Unix faithful. Dough McIlroy offered this story concerning egrep
to the conversation. The egrep
connection is that it was egrep
’s regex technology that powered AWK.
McIlroy explains that for years he thought he was responsible for getting Ken Thompson to cut the regex code from ed
and turn it into grep
. He learned much later—through the THUS mailing list—that, in fact, Thompson had already done that to make a tool for his own use and all that really happened was that McIlroy’s urging got him to make it publicly available.
McIlroy goes on to say that he used egrep
as an integral part of his calendar
program but that it painfully slow. Al Aho, the developer of egrep
was mortified and introduced lazy state building to egrep
to make it faster. That worked but now McIlroy wonders whether he really inspired Aho to make the change or whether it was something he had already planned.
A bit later Mohamed Akram sent a message saying that he had written a blog post about calendar
that explains what it does and how it does it. The TL;DR is that it’s a simple script that calls a C program to build a regex and then uses that regex in an egrep
call to extract the desired information from the calendar file. Read Akram’s post for the details and the code.
McIlroy is a master at this sort of thing and calendar
is a nice example of the way he leveraged existing tools tied together with a shell script to get things done.