delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/07/16/22:04:35

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:mime-version:content-type
:content-transfer-encoding:message-id:date:from:to:subject
:in-reply-to:references; q=dns; s=default; b=I5TyQL+tooIcLzh1o+n
FIvQChgwJGa2ie3TC75j44DDVl45m9aroI1TxtwMJkTWUrHI6jQsJo0yZPn+M2vk
xdtsE2/AnrF0aAz4uLKoYsn8zy5sAekwED87Q1S7yBL9WIlSGgZlN+ZLlW0EQ7yO
LD2W64ZLFal2CsFMy7kPYlK4=
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:mime-version:content-type
:content-transfer-encoding:message-id:date:from:to:subject
:in-reply-to:references; s=default; bh=s06Por/EZ2/iHrrTnfqomE6jK
xM=; b=YdAG+DHAyg5fflh3kJveHOPKkEe4uUHwJNdK/coSMhLZpc9MPFzpakNY2
U7GqKPXF3fgpPIAQvekpQi9Ar7veXgs7Qfll95gfQ20kufj1kRUz93pP4lHfxBQU
azgAH9hv3ZsqLokyfJo1iArCG41QWG3ZX1GIXwf8CZQ7f3FQwA=
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.3 required=5.0 tests=AWL,BAYES_50,HK_RANDOM_ENVFROM,HK_RANDOM_FROM,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2
X-HELO: sneak2.sneakemail.com
MIME-Version: 1.0
Message-ID: <6138-1437098652-808922@sneakemail.com>
Date: Thu, 16 Jul 2015 20:04:10 -0600
From: "John Hein" <3fbmqnhaz4 AT snkmail DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: --line-regexp option with null data
In-Reply-To: <CAAXzdLWo4nvaJBMOBYsOYeCdrgw_O=8CM_H_kwfxnU=AqnuOjA@mail.gmail.com>
References: <CAAXzdLWo4nvaJBMOBYsOYeCdrgw_O=8CM_H_kwfxnU=AqnuOjA AT mail DOT gmail DOT com>

Steven Penny svnpenn-at-gmail.com |cygwin_ml_nodigest| wrote at 20:29 -0500 on Jul 16, 2015:
 > Consider this command:
 >
 >     printf 'alpha\nbravo\ncharlie\n' | grep --line-regexp --quiet bravo
 >
 > grep sees 3 lines separated by newline, and matches the bravo line. Now consider
 > this command:
 >
 >     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` followed 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 expected.
 >
 > http://stackoverflow.com/q/31467045

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.

That does seem like a bug in the cygwin implementation of grep to me.

As a workaround for this simple example, you can add -a (aka --text)
to force it to treat the input as text.

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019