bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

please allow a list of files to grep, as a file that can be - for stdin


From: Santiago José Ruano Rincón
Subject: please allow a list of files to grep, as a file that can be - for stdin (fixes other bugs)
Date: Sat, 27 May 2006 18:48:42 -0500

Hi, 

I'm forwarding a grep bug report from the Debian bug tracking system. Please, 
consider it.

Kind regards,

Santiago Ruano Rincón

PD. Please Cc: address@hidden when you reply.

----

Package: grep
Version: 2.5.1.ds2-5
Severity: wishlist


this partly fixes other bugs, including part of the bug that i just
filed on symlink recursion and these:

 Outstanding bugs -- Minor bugs; Unclassified (7 bugs): 1 report
  1) #297154: grep: Please warn requesting recursion of stdin

 Outstanding bugs -- Wishlist items; Unclassified (11 bugs): 2 reports
  2) #177180: a "one filesystem" recursion option would be nice
  3) #283094: Option to ignore certain directories (e.g., .svn) while recursing

===

grep should have an option that takes a list of files to grep.  it should
allow - for stdin so that you can do this:

        find ... -xdev |
                grep -v .svn/ |
                grep -r --files-input - apple

it should also allow for the files to be terminated by NUL.

you might think that xargs can achieve the same effect, but that
is incorrect.  consider:

        find ... -xdev |
                grep -v .svn/ |
                xargs ... grep apple

with the proposed option grep handles -h and -H properly.  with the
xargs solution there is no way to print the filenames.

you might then think that a shell loop can achieve the same effect,
but consider what many people will do:

        find ... -xdev |
                grep -v .svn/ |
                while read i
                do
                        grep apple "$i"
                done

first, i is polluted.  second, this will not get all filenames.  read
does not have an option that is portable among bash, sh, and zsh that
will do a raw read -- try leading whitespace.  this gets unbelievably
complicated to fix.  you have to use special IFS settings and even
then it is fiendish.

you might argue that this is the fault of sh, bash, and zsh for making
it insanely difficult to do a shell xargs (which i call mapcar).  you
would be absolutely correct (maybe i will file a bug report).

but fixing grep is a cheap workaround that i think is convenient
enough to be worth the fact that the correct thing to do is to fix the
shells instead.

and, even though a shell xargs/mapcar works fine, you'll still get
bug reports like the above if you do not, by people who don't know
about xargs and mapcar.  if the shell gets fixed, then you can put
that in the manpage.

thanks.

-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.11--from-2.6.9-proc-config-and-menuconfig
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages grep depends on:
ii  libc6                         2.3.6-7    GNU C Library: Shared libraries

grep recommends no packages.

-- no debconf information

Attachment: signature.asc
Description: Esta parte del mensaje está firmada digitalmente


reply via email to

[Prev in Thread] Current Thread [Next in Thread]