From unknown Tue Jun 24 03:23:05 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#14391 <14391@debbugs.gnu.org> To: bug#14391 <14391@debbugs.gnu.org> Subject: Status: bug in grep -- ignoring GREP_OPTIONS or not acting on it... Reply-To: bug#14391 <14391@debbugs.gnu.org> Date: Tue, 24 Jun 2025 10:23:05 +0000 retitle 14391 bug in grep -- ignoring GREP_OPTIONS or not acting on it... reassign 14391 coreutils submitter 14391 Linda Walsh severity 14391 normal tag 14391 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Sun May 12 01:05:02 2013 Received: (at submit) by debbugs.gnu.org; 12 May 2013 05:05:02 +0000 Received: from localhost ([127.0.0.1]:37089 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UbOSz-0006Wu-38 for submit@debbugs.gnu.org; Sun, 12 May 2013 01:05:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58806) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UbOSx-0006Wj-D0 for submit@debbugs.gnu.org; Sun, 12 May 2013 01:05:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UbOSc-000585-Jd for submit@debbugs.gnu.org; Sun, 12 May 2013 01:04:39 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-100.6 required=5.0 tests=BAYES_40,RP_MATCHES_RCVD, USER_IN_WHITELIST autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:36115) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbOSc-000581-GO for submit@debbugs.gnu.org; Sun, 12 May 2013 01:04:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbOSb-0007Tm-JS for bug-coreutils@gnu.org; Sun, 12 May 2013 01:04:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UbOSa-00057q-O3 for bug-coreutils@gnu.org; Sun, 12 May 2013 01:04:37 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:43694 helo=Ishtar.hs) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbOSZ-00056q-OY for bug-coreutils@gnu.org; Sun, 12 May 2013 01:04:36 -0400 Received: from [192.168.4.12] (Athenae [192.168.4.12]) by Ishtar.hs (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id r4C54QLU071850 for ; Sat, 11 May 2013 22:04:29 -0700 Message-ID: <518F22DA.7000607@tlinx.org> Date: Sat, 11 May 2013 22:04:26 -0700 From: Linda Walsh User-Agent: Thunderbird MIME-Version: 1.0 To: bug-coreutils@gnu.org Subject: bug in grep -- ignoring GREP_OPTIONS or not acting on it... Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) My grep is : grep (GNU grep) 2.14 Copyright (C) 2012 Free Software Foundation, Inc. ... when I type grep, I get an alias + I have GREP_OPTIONS set.. whence on grep gives the first entry as: grep is aliased to `grep --color=auto' > echo $GREP_OPTIONS -D skip --binary-files=without-match Ishtar:/tmp/test> ll total 0 drwxrwxr-x 2 6 May 11 14:39 a/ drwxrwxr-x 2 6 May 11 14:39 b/ drwxrwxr-x 2 6 May 11 14:39 c/ -rw-rw-r-- 1 0 May 11 14:39 e -rw-rw-r-- 1 0 May 11 14:39 f -rw-rw-r-- 1 0 May 11 14:39 g Ishtar:/tmp/test> grep foo * grep: a: Is a directory grep: b: Is a directory grep: c: Is a directory grep should ignore the directories and issue no message for them: -D ACTION, --devices=ACTION If an input file is a device, FIFO or socket, use ACTION to process it. By default, ACTION is read, which means that devices are read just as if they were ordinary files. If ACTION is skip, devices are silently skipped. GREP_OPTIONS This variable specifies default options to be placed in front of any explicit options. For example, if GREP_OPTIONS is '--binary-files=without-match --directories=skip', grep behaves as if the two options --binary-files=without-match and --directories=skip had been specified before any explicit options. ---- ACTION=skip, so where's the silence? I don't remember this being this way before -- it used to work. Seems like it stopped recently? From debbugs-submit-bounces@debbugs.gnu.org Sun May 12 08:24:17 2013 Received: (at 14391) by debbugs.gnu.org; 12 May 2013 12:24:18 +0000 Received: from localhost ([127.0.0.1]:37238 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UbVK3-0003Ve-DZ for submit@debbugs.gnu.org; Sun, 12 May 2013 08:24:17 -0400 Received: from mail3.vodafone.ie ([213.233.128.45]:48344) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UbVJy-0003V9-Sb; Sun, 12 May 2013 08:24:12 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkIDAHyJj1FtTZTj/2dsb2JhbAANTYZ6uXWCbAMBgReDEwEBAQQjDwE7CxALDQEKAgIFFgsCAgkDAgECAUUGDQEHAQGyE3KQG4EmjDVuXweCQoETA51lg1iKNA Received: from unknown (HELO [192.168.1.79]) ([109.77.148.227]) by mail3.vodafone.ie with ESMTP; 12 May 2013 13:23:47 +0100 Message-ID: <518F89D3.1050605@draigBrady.com> Date: Sun, 12 May 2013 13:23:47 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#14391: bug in grep -- ignoring GREP_OPTIONS or not acting on it... References: <518F22DA.7000607@tlinx.org> In-Reply-To: <518F22DA.7000607@tlinx.org> X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 14391 Cc: 14391@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) tag 14391 notabug close 14391 stop grep is not a coreutils so closing this. You may want to discuss this on the grep mailing list, but I've added a couple of notes below. On 05/12/2013 06:04 AM, Linda Walsh wrote: > My grep is : > grep (GNU grep) 2.14 > Copyright (C) 2012 Free Software Foundation, Inc. > ... > when I type grep, I get an alias + I have GREP_OPTIONS set.. > > whence on grep gives the first entry as: > grep is aliased to `grep --color=auto' > >> echo $GREP_OPTIONS > -D skip --binary-files=without-match > > Ishtar:/tmp/test> ll > total 0 > drwxrwxr-x 2 6 May 11 14:39 a/ > drwxrwxr-x 2 6 May 11 14:39 b/ > drwxrwxr-x 2 6 May 11 14:39 c/ > -rw-rw-r-- 1 0 May 11 14:39 e > -rw-rw-r-- 1 0 May 11 14:39 f > -rw-rw-r-- 1 0 May 11 14:39 g > Ishtar:/tmp/test> grep foo * > grep: a: Is a directory > grep: b: Is a directory > grep: c: Is a directory > > grep should ignore the directories and issue no message for them: > -D ACTION, --devices=ACTION > If an input file is a device, FIFO or socket, use ACTION to > process it. By default, ACTION is read, which means that > devices are read just as if they were ordinary files. If ACTION > is skip, devices are silently skipped. > > GREP_OPTIONS > This variable specifies default options to be placed in front of > any explicit options. For example, if GREP_OPTIONS is > '--binary-files=without-match --directories=skip', grep behaves > as if the two options --binary-files=without-match and > --directories=skip had been specified before any explicit > options. > ---- > ACTION=skip, so where's the silence? > > I don't remember this being this way before -- it used to work. > Seems like it stopped recently? While I see that grep 2.9 at least doesn't seem to warn about dirs by default, for newer versions you may want to specify -d 'skip' instead of -D 'skip' ? thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Sun May 12 19:57:34 2013 Received: (at 14391) by debbugs.gnu.org; 12 May 2013 23:57:34 +0000 Received: from localhost ([127.0.0.1]:37902 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ubg90-0000fL-67 for submit@debbugs.gnu.org; Sun, 12 May 2013 19:57:34 -0400 Received: from joseki.proulx.com ([216.17.153.58]:50533) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ubg8x-0000fE-Rl for 14391@debbugs.gnu.org; Sun, 12 May 2013 19:57:33 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 16136211E3 for <14391@debbugs.gnu.org>; Sun, 12 May 2013 17:57:07 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id 010972DC44; Sun, 12 May 2013 17:57:06 -0600 (MDT) Date: Sun, 12 May 2013 17:57:06 -0600 From: Bob Proulx To: 14391@debbugs.gnu.org Subject: Re: bug#14391: bug in grep -- ignoring GREP_OPTIONS or not acting on it... Message-ID: <20130512235706.GA21328@hysteria.proulx.com> References: <518F22DA.7000607@tlinx.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <518F22DA.7000607@tlinx.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 14391 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.5 (--) Of course this needs to go over to bug-grep but here is my comment anyway... Linda Walsh wrote: > when I type grep, I get an alias + I have GREP_OPTIONS set.. > grep is aliased to `grep --color=auto' > > echo $GREP_OPTIONS > -D skip --binary-files=without-match > Ishtar:/tmp/test> grep foo * > grep: a: Is a directory > grep: b: Is a directory > grep: c: Is a directory Basically: grep -D skip --binary-files=without-match --color=auto foo * > grep should ignore the directories and issue no message for them: > -D ACTION, --devices=ACTION > If an input file is a device, FIFO or socket, use ACTION to > process it. By default, ACTION is read, which means that > devices are read just as if they were ordinary files. If ACTION > is skip, devices are silently skipped. > ... > ... > I don't remember this being this way before -- it used to work. > Seems like it stopped recently? I think you need --directories=skip in addition to --devices=skip. Add -d skip to your option list. grep -D skip -d skip --binary-files=without-match --color=auto foo * This is an example of why I think grep should never have added directory recursion. It needs to suck in all of 'find' before it will be complete. And that doesn't make sense because there is already find available. find . -type f -exec grep foo {} + That isn't precisely the same as the grep case you posted but it is usually what people want. For -D skip it would need to be more like this: find . -follow ! -type d -exec grep foo {} + If there were often used favorite options then I would turn them into either a shell script or a shell function. Bob From debbugs-submit-bounces@debbugs.gnu.org Tue May 14 13:34:10 2013 Received: (at 14391) by debbugs.gnu.org; 14 May 2013 17:34:10 +0000 Received: from localhost ([127.0.0.1]:44377 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UcJ73-0000QW-1V for submit@debbugs.gnu.org; Tue, 14 May 2013 13:34:09 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:39789 helo=Ishtar.hs) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UcJ5c-0000MO-OJ for 14391@debbugs.gnu.org; Tue, 14 May 2013 13:32:44 -0400 Received: from [192.168.4.12] (Athenae [192.168.4.12]) by Ishtar.hs (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id r4EHWWBt002397; Tue, 14 May 2013 10:32:34 -0700 Message-ID: <5192752F.4040305@tlinx.org> Date: Tue, 14 May 2013 10:32:31 -0700 From: Linda Walsh User-Agent: Thunderbird MIME-Version: 1.0 To: Bob Proulx Subject: Re: bug#14391: bug in grep -- ignoring GREP_OPTIONS or not acting on it... References: <518F22DA.7000607@tlinx.org> <20130512235706.GA21328@hysteria.proulx.com> In-Reply-To: <20130512235706.GA21328@hysteria.proulx.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 14391 X-Mailman-Approved-At: Tue, 14 May 2013 13:34:07 -0400 Cc: 14391@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.5 (--) Bob Proulx wrote: > > Basically: > > I think you need --directories=skip in addition to --devices=skip. > Add -d skip to your option list. > > grep -D skip -d skip --binary-files=without-match --color=auto foo * > > This is an example of why I think grep should never have added > directory recursion. It needs to suck in all of 'find' before it will > be complete. And that doesn't make sense because there is already > find available. > > find . -type f -exec grep foo {} + > > That isn't precisely the same as the grep case you posted but it is > usually what people want. For -D skip it would need to be more like > this: > > find . -follow ! -type d -exec grep foo {} + > > If there were often used favorite options then I would turn them into > either a shell script or a shell function. ---- Very good points -- especially about my broken options (I could swear they worked in the past)...must have gotten accidently deleted somewhere along in the past. But .. I also agree with the problems of grep possibly calling find inefficiently. I would have thought it smarter to call find as a child, and read from it's pipe and call the file-search on large groups at a time. Otherwise, if grep waited for all of find to complete, as you are suggesting, might it not run out of space to hold the paths of the files it is going to search? From debbugs-submit-bounces@debbugs.gnu.org Tue May 14 14:00:57 2013 Received: (at 14391) by debbugs.gnu.org; 14 May 2013 18:00:57 +0000 Received: from localhost ([127.0.0.1]:44394 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UcJWx-0002KC-RI for submit@debbugs.gnu.org; Tue, 14 May 2013 14:00:56 -0400 Received: from joseki.proulx.com ([216.17.153.58]:59797) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UcJWu-0002IG-0L for 14391@debbugs.gnu.org; Tue, 14 May 2013 14:00:54 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 3A1B4211DD for <14391@debbugs.gnu.org>; Tue, 14 May 2013 12:00:50 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id 0DD1C2DCCE; Tue, 14 May 2013 12:00:49 -0600 (MDT) Date: Tue, 14 May 2013 12:00:49 -0600 From: Bob Proulx To: 14391@debbugs.gnu.org Subject: Re: bug#14391: bug in grep -- ignoring GREP_OPTIONS or not acting on it... Message-ID: <20130514180049.GB29891@hysteria.proulx.com> References: <518F22DA.7000607@tlinx.org> <20130512235706.GA21328@hysteria.proulx.com> <5192752F.4040305@tlinx.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5192752F.4040305@tlinx.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -0.6 (/) X-Debbugs-Envelope-To: 14391 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.5 (--) Linda Walsh wrote: > Bob Proulx wrote: > > Basically: > > > > I think you need --directories=skip in addition to --devices=skip. > > Add -d skip to your option list. > > > > grep -D skip -d skip --binary-files=without-match --color=auto foo * > Very good points -- especially about my broken options (I could > swear they worked in the past)...must have gotten accidently deleted > somewhere along in the past. It probably did work in the past. If you look through all of the previous grep versions you will probably find at least one where that combination worked. I didn't mean to say otherwise. I remember grep's recursion behavior as having gone through several iterations of changes. It hasn't matured yet. But hopefully the changes are slowing down. :-) > > This is an example of why I think grep should never have added > > directory recursion. It needs to suck in all of 'find' before it will > > be complete. And that doesn't make sense because there is already > > find available. > > > > find . -type f -exec grep foo {} + > > But .. I also agree with the problems of grep possibly calling find > inefficiently. I would have thought it smarter to call find as a > child, and read from it's pipe and call the file-search on large > groups at a time. Otherwise, if grep waited for all of find to > complete, as you are suggesting, might it not run out of space to > hold the paths of the files it is going to search? Using the above with "{} +" is very efficient. It will not exceed ARG_MAX. The "{} +" part of the find instructs find to: 3.3.2 Multiple Files -------------------- Sometimes you need to process files one at a time. But usually this is not necessary, and, it is faster to run a command on as many files as possible at a time, rather than once per file. Doing this saves on the time it takes to start up the command each time. The `-execdir' and `-exec' actions have variants that build command lines containing as many matched files as possible. -- Action: -execdir command {} + This works as for `-execdir command ;', except that the `{}' at the end of the command is expanded to a list of names of matching files. This expansion is done in such a way as to avoid exceeding the maximum command line length available on the system. Only one `{}' is allowed within the command, and it must appear at the end, immediately before the `+'. A `+' appearing in any position other than immediately after `{}' is not considered to be special (that is, it does not terminate the command). -- Action: -exec command {} + This insecure variant of the `-execdir' action is specified by POSIX. The main difference is that the command is executed in the directory from which `find' was invoked, meaning that `{}' is expanded to a relative path starting with the name of one of the starting directories, rather than just the basename of the matched file. The old traditional way was "\;" (needed to be quoted to protect it from the shell) which invoked the command once for each argument. The new standard way is "+" which bundles up as many arguments as possible, will not exceed ARG_MAX, and therefore is quite efficient. Also it doesn't need to be special quoting making it more convenient. Using 'find . -print0 | grep --files0-from=- ...', if implemented, would also be efficient. But not implemented AFAIK. I think the "insecure" warning is too agressive and overstating the point. Bob From unknown Tue Jun 24 03:23:05 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 12 Jun 2013 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator