This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: [ANNOUNCEMENT] Updated: grep-2.6.3-1
- From: ht at inf dot ed dot ac dot uk (Henry S. Thompson)
- To: cygwin at cygwin dot com
- Date: Fri, 27 Aug 2010 14:32:31 +0100
- Subject: Re: [ANNOUNCEMENT] Updated: grep-2.6.3-1
- References: <announce.20100720212708.GA13740@ednor.casa.cgf.cx>
cgf wrote:
> Note that [now] grep opens files in binary mode for both reading and writing
> so the output of grep will always have \n endings unless you specify the
> --binary option which will (perhaps paradoxically) force the output to
> reflect exactly what was in the file being grepped.
For those of us who only RTFM [1] when forced to, I learned the hard way
that the mapping of \r\n to \n implied above actually happens on
_input_, so many patterns involving \r will fail w/o --binary.
You have been warned.
ht
[1] The online documentation reads:
By default, under ms-dos and ms-Windows, grep guesses the file type
by looking at the contents of the first 32kB read from the file. If
grep decides the file is a text file, it strips the CR characters
from the original file contents (to make regular expressions with ^
and $ work correctly). Specifying [--binary] overrules this
guesswork, causing all files to be read and passed to the matching
mechanism verbatim; if the file is a text file with CR/LF pairs at
the end of each line, this will cause some regular expressions to
fail. This option has no effect on platforms other than ms-dos and
ms-Windows.
--
Henry S. Thompson, School of Informatics, University of Edinburgh
10 Crichton Street, Edinburgh EH8 9AB, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 651-1426, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail from me _always_ has a .sig like this -- mail without it is forged spam]
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple