GNU bug report logs - #21621
Bug | grep | Running in loop

Previous Next

Package: grep;

Reported by: Gino Atlas <ga <at> gino-atlas.de>

Date: Mon, 5 Oct 2015 15:22:02 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


Message #12 received at 21621-done <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Gino Atlas <ga <at> gino-atlas.de>, 21621-done <at> debbugs.gnu.org
Subject: Re: bug#21621: Bug | grep | Running in loop
Date: Mon, 5 Oct 2015 14:39:56 -0600
[Message part 1 (text/plain, inline)]
tag 21621 notabug
thanks

On 10/05/2015 07:29 AM, Gino Atlas wrote:
> Dear ladies and gentlemen,
> 
> I would like to report a bug.
> When I run this command:
> grep -rl '^PATTERN$'.
> ^C
> (Pay attention to the non-whitespace between pattern and target directory.)
> 
> It seems like it’s running in a loop, though, I was expecting a timeout
> would occur after a while.
> Can you confirm it's a bug and the behaviour is expected?
> 

Yes, that is the expected behavior.  You didn't tell grep what file to
read, so it is defaulting to reading stdin.  But stdin is your terminal,
and grep is waiting for you to type.  When you are done with your input,
type Ctrl-D to tell the terminal to send an EOF to grep, so that it can
quit reading stdin.

Perhaps it could be argued that grep should recognize when its stdin is
a terminal, and issue a warning to the user that they may have forgotten
to specify an input location and to press ctrl-D to break out of grep
waiting for the user to type something.  But GNU Coding Standards
discourage a program behaving differently merely because stdin is a
terminal.

At any rate, since the behavior is intentional, and since grep is
waiting for you to do something (it is NOT burning 100% CPU during that
wait), I'm marking this as not a bug. However, feel free to add more
comments or questions on the topic.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 9 years and 288 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.