delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:subject:to:references:from:message-id:date | |
:mime-version:in-reply-to:content-type; q=dns; s=default; b=IwkB | |
ywtxgrUQfi9aCYzfhTI8Gkr8i46HV16TTAgeShg/iLCWPpZ1DavkxFPsHrpN7Hin | |
7lHvQlxvHIS4TLbRyOGiob0O478RMqcFs3dhAcmnuEqc8ikcAkwQsw8PU95hxU7u | |
EFkExDxzySTG8FlbMus9cATp1Ao9B6RepVuA+Zs= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:subject:to:references:from:message-id:date | |
:mime-version:in-reply-to:content-type; s=default; bh=DjUcCxgT5J | |
4frOwwDo5Dsj6Cw7s=; b=Ovb2JPlAjykncwA8HfGGEDH98BXw3MXtRaoSd1I7Lg | |
X/oxjYtul3vEFIWZ65tQw6Ycii+6/rY4u68bbjhPHHBxG9MOT/dfGg9QcIQzu/Xv | |
REwh1H2ttMOaMFDfTx8ssHMyYgVrAt3eXHtZ8M1QUPIjBuQlPSMGybby+WkPM3zo | |
I= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=-2.0 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 |
X-HELO: | mx1.redhat.com |
Subject: | Re: --line-regexp option with null data |
To: | cygwin AT cygwin DOT com |
References: | <CAAXzdLWo4nvaJBMOBYsOYeCdrgw_O=8CM_H_kwfxnU=AqnuOjA AT mail DOT gmail DOT com> <6138-1437098652-808922 AT sneakemail DOT com> |
From: | Eric Blake <eblake AT redhat DOT com> |
Openpgp: | url=http://people.redhat.com/eblake/eblake.gpg |
Message-ID: | <55A8ED20.8050509@redhat.com> |
Date: | Fri, 17 Jul 2015 05:55:12 -0600 |
User-Agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 |
MIME-Version: | 1.0 |
In-Reply-To: | <6138-1437098652-808922@sneakemail.com> |
X-IsSubscribed: | yes |
--kbM5MhfaW3oR5mClJUGsbcwk2B7IglmVg Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/16/2015 08:04 PM, John Hein wrote: > > printf 'alpha\0bravo\0charlie\0' | grep --line-regexp --quiet bravo > > > > My thinking tells me that because I have not used `--null-data`, grep = should see > > 1 or even 0 lines separated by newline, and fail to match a `bravo` fo= llowed by > > newline. However it does not, it succeeds just like the first command,= why is > > this? > > > > Note I also tried this on Debian with Grep 2.2 and it works as expecte= d. > > > > http://stackoverflow.com/q/31467045 >=20 > cygwin grep is detecting the input as binary which seems to be > overriding the 'match the whole line' behavior of --line-regexp. Get > rid of --quiet to see that. The behavior on Linux is the same. See the NEWS for grep 2.21: When searching binary data, grep now may treat non-text bytes as line terminators. This can boost performance significantly. >=20 > That does seem like a bug in the cygwin implementation of grep to me. No, it is intentional upstream behavior. >=20 > As a workaround for this simple example, you can add -a (aka --text) > to force it to treat the input as text. Yes, that IS the correct solution. You must TELL grep to not treat \0 as a line terminator. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --kbM5MhfaW3oR5mClJUGsbcwk2B7IglmVg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVqO0gAAoJEKeha0olJ0NqdTgH/RJu72NgcK0mThOQBEV/tX2p 9Jy55oR/HL2zvwXcJT4USD5RymGi5qPJCT8DQQfxYJ+xL5lEd+IRK4oVny6O8H1X dAToi5XhRdVQq4PKtgoQ1vycl3/zywD9QpIztudGigZvKeXFmtBQj91LZcG7W72/ EfAem18zaqZhHEDf6ZPsI6Gk5xcn9drAEqFQG/LUaqcQrhmWoOJ+xiEm6bD48cn/ ICF/c8tZtafFOjEVXqcN+dRZdotYGDo5YpFQfVxNrGkmXKphTofFCyAxw83ncEO5 az09+TDyBus0EvP0FxMyJoQfUGS9288BU9IlYf3tPumILRMoTLOSwkaEPscd8uY= =Jwkn -----END PGP SIGNATURE----- --kbM5MhfaW3oR5mClJUGsbcwk2B7IglmVg--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |