grep replacement
Brandon S. Allbery
allbery at ncoast.UUCP
Mon Jun 20 00:13:41 AEST 1988
As quoted from <5826 at umn-cs.cs.umn.edu> by randy at umn-cs.cs.umn.edu (Randy Orrison):
+---------------
| In article <7962 at alice.UUCP> andrew at alice.UUCP writes:
| |3) print lines with context.
| | the second most requested feature but i'm not doing it. this is
| | just the job for sed. to be consistent, we just took the context
| ^^^^^^^^^^^^^^^^
| | crap out of diff too. this is actually reasonable; showing context
| ^^^^^^^^^^^^^^^^
| | is the job for a separate tool (pipeline difficulties apart).
|
|
| What?!?!? Ok, i would like context in grep, but i'll live without it.
| Context diffs, however are a different matter. There isn't an easy way
| to generate them with diff/context (the first character of every line is
| produced as part of the diff). Context diffs are useful for patches, and
+---------------
Yes, there is; change diff's output format slightly and expand "context"
slightly, then other programs can also output in "extended context" format so
as to use "context"'s facilities. I've already described part of this
change in another posting; the other part would be to recognize a special
indicator (on the line number, perhaps?) which would for generality be the
flag to use on the difference, defaulting to "*" which is what "context"
currently uses, or diff could specify "+", "-", or "!". The only other
change would be to smarten "context" so that it "collapses" context
"windows" together much like the 4.3BSD diff -c does.
It appears that Bell Labs continues to use tools unrepentantly. It should
be noted that they *are* into research, so I have no arguments against their
use of /dev/stdin (/dev/fd/0?), their assumption that there's plenty of
space so stash away a copy of a file with "tee" for later use in "context",
etc. (My /dev/stdin complaint earlier was not aimed at the Bell Labs folks,
it was aimed at the person who informed the entire Usenet that "hey, I
posted a /dev/stdin driver source for 4.2BSD, so not a one of you has any
reason not to be running it". In other words, the usual 4.xBSD-source
elitism.)
--
Brandon S. Allbery | "Given its constituency, the only
uunet!marque,sun!mandrill}!ncoast!allbery | thing I expect to be "open" about
Delphi: ALLBERY MCI Mail: BALLBERY | [the Open Software Foundation] is
comp.sources.misc: ncoast!sources-misc | its mouth." --John Gilmore
More information about the Comp.unix.questions
mailing list