RE: Altered behaviour of grep

2015-03-24 Thread Fergus Daly
grep -Pl \xmn
used to find files containing the ASCII character mn. For instance
grep -PL \x0d or \x0a or usefully \x00.
   ^
I did mean grep -Pl in both cases.
Fergus
 

--
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



Re: Altered behaviour of grep

2015-03-24 Thread Corinna Vinschen
On Mar 24 08:07, Fergus Daly wrote:
 grep -Pl \xmn
 used to find files containing the ASCII character mn. For instance
 grep -PL \x0d or \x0a or usefully \x00.
 This seems to have been lost with the current version.
 Is this an error? If not, can anybody tell me what new syntax will recover 
 the old behaviour?

I just tested this on Cygwin and Fedora 21, both with grep 2.21:

  $ cat x.sh
  #!/bin/sh
  echo ${0##*/}
  $ grep -Pl '\x30' x.sh
  x.sh
  $ grep -Pl '\x0a' x.sh
  $ 

Same result on both systems, so it finds characters in lines, but not
the line separator itself.  If that worked before, this looks like an
upstream change to me.

A bit of digging shows this thread on the bug-grep mailing list:
http://lists.gnu.org/archive/html/bug-grep/2015-03/msg00015.html

And indeed, if I add a NUL byte to the file and search for it:

 $ grep -Pl '\x0' x.sh
 $ grep -aPl '\x0' x.sh
 x.sh

This does not work for the CR or LF, though.  You may want to discuss
this on the bug-grep ML.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


pgpMy_vdTWdjZ.pgp
Description: PGP signature