bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: grep RFE: End-of-Line choices


From: Stepan Kasal
Subject: Re: grep RFE: End-of-Line choices
Date: Fri, 27 Feb 2004 09:21:16 +0100
User-agent: Mutt/1.4.1i

Hello,

> > Tyson wrote:
> > >   --eol=<vals>
> > > where <vals> =  <eol>(,<eol>)*
> > > where <eol> = LF | CR | CRLF
> > > The default would be OS-specific.  For most unix

I've changed my mind a bit: perhaps there should be no new option,
see below for details.

On Thu, Feb 26, 2004 at 05:26:13PM +0100, Claudio Fontana wrote:
> 1) isn't 0x0d, 0x0a trasparently handled by C as char
> '\n' under DOS/Win? In this case I would suspect that
> only the two values LF | CR would be needed.

No, the C library's O_TEXT feature is not used by grep.
Grep takes care to open all files in binary mode, and all the quirks
are part of grep---see src/dosbuf.c .

> 2) stated that the eol character is handled by
> variable eolbyte for both grepping and outputting, and

This approach would not work if you
        cat unix-file.txt mac-file.txt | grep

In other words, it might be desirable that both \n and \r work in the
same input file, which cannot be achieved by mere change of eolbyte.

I don't have Mac either, so I'm not able to judge neither this nor
> [whether] can the \r be sent to the terminal

> 3) I would be glad to implement the feature if it's
> needed and it is not already being implemented. Is it?

I'm not sure how much it's needed and when is "tr \\r \\n" enough.
And I'm not aware that anyone is working on it.

I'd say that it should be designed by someone who "lives in the Mac
tradition", or at least by close cooperation of Unix programmer and
Mac power user.

Perhaps we don't need the new general option.  The solution could be
anlogous to DOS grep: some OS-specific quirks are compiled in, and
can be switched off by the option "-U, --binary" .

I cannot judge whether it would be better to extend dosbuf.c to serve
both for DOS and Mac, or to make a separate macbuf.c .
(But I have to say that I'm really happy that current dosbuf.c is not
compiled into the unix version of grep.)

I'd be glad to hear from you if you're going to hack this.

Have a nice day,
        Stepan Kasal




reply via email to

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