From unknown Wed Aug 20 04:12:23 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#19998 <19998@debbugs.gnu.org> To: bug#19998 <19998@debbugs.gnu.org> Subject: Status: GREP_OPTIONS alternative? Reply-To: bug#19998 <19998@debbugs.gnu.org> Date: Wed, 20 Aug 2025 11:12:23 +0000 retitle 19998 GREP_OPTIONS alternative? reassign 19998 grep submitter 19998 Christian Kujau severity 19998 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 04 02:08:21 2015 Received: (at submit) by debbugs.gnu.org; 4 Mar 2015 07:08:21 +0000 Received: from localhost ([127.0.0.1]:34476 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YT3Po-0007q8-TF for submit@debbugs.gnu.org; Wed, 04 Mar 2015 02:08:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50419) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YT2HO-0005w3-7C for submit@debbugs.gnu.org; Wed, 04 Mar 2015 00:55:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YT2HH-0006id-Vj for submit@debbugs.gnu.org; Wed, 04 Mar 2015 00:55:28 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:43743) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YT2HH-0006iZ-FY for submit@debbugs.gnu.org; Wed, 04 Mar 2015 00:55:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YT2HG-0008UE-G7 for bug-grep@gnu.org; Wed, 04 Mar 2015 00:55:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YT2HC-0006iH-BC for bug-grep@gnu.org; Wed, 04 Mar 2015 00:55:26 -0500 Received: from trent.utfs.org ([94.185.90.103]:59217) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YT2HC-0006iC-63 for bug-grep@gnu.org; Wed, 04 Mar 2015 00:55:22 -0500 Received: by trent.utfs.org (Postfix, from userid 8) id D1BFA3DB4F; Wed, 4 Mar 2015 06:55:19 +0100 (CET) Received: from trent.utfs.org (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id 289953DB05 for ; Wed, 4 Mar 2015 06:55:19 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id 072B23DA38 for ; Wed, 4 Mar 2015 06:55:19 +0100 (CET) Date: Tue, 3 Mar 2015 21:55:18 -0800 (PST) From: Christian Kujau To: bug-grep@gnu.org Subject: GREP_OPTIONS alternative? Message-ID: User-Agent: Alpine 2.19.4 (DEB 40 2013-11-18) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-AV-Checked: ClamAV using ClamSMTP (127.0.0.1 at Wed Mar 4 06:55:19 2015 +0100 (CET)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 04 Mar 2015 02:08:19 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Hi, much to my dismay I noticed that GREP_OPTIONS has been made obsolete. I usually kept the following in my .profile: export GREP_OPTIONS='--color=tty --devices=skip' which was honored by GNU/grep and BSD/grep and ignored by e.g SUNWcsu/grep. Without GREP_OPTIONS, I have to put something like this in my .profile: if grep --version 2>/dev/null | egrep -q 'GNU|BSD' 2>/dev/null; then alias grep='grep --color=auto --devices=skip' fi But that leaves out all the other grep variants, so what I really have in my .profile now is something like this: if grep --version 2>/dev/null | egrep -q 'GNU|BSD' 2>/dev/null; then alias grep='grep --color=auto --devices=skip' alias egrep='egrep --color=auto --devices=skip' alias fgrep='fgrep --color=auto --devices=skip' alias zgrep='zgrep --color=auto --devices=skip' alias bzgrep='bzgrep --color=auto --devices=skip' alias xzgrep='xzgrep --color=auto --devices=skip' fi (and even that leaves out bzegrep, xzfgrep, etc.) I suspect that I'm doing it wrong - but what's the alternative to have some nice grep defaults and still be portable across platforms? Thanks, Christian. -- BOFH excuse #355: Boredom in the Kernel. From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 04 17:43:57 2015 Received: (at 19998) by debbugs.gnu.org; 4 Mar 2015 22:43:57 +0000 Received: from localhost ([127.0.0.1]:35335 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YTI1F-0000ji-GU for submit@debbugs.gnu.org; Wed, 04 Mar 2015 17:43:57 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:50709) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YTI1C-0000jR-2g for 19998@debbugs.gnu.org; Wed, 04 Mar 2015 17:43:55 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id B0272A60044; Wed, 4 Mar 2015 14:43:47 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hY+rLV44PjGf; Wed, 4 Mar 2015 14:43:47 -0800 (PST) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 466EEA6003F; Wed, 4 Mar 2015 14:43:47 -0800 (PST) Message-ID: <54F78A9D.1040904@cs.ucla.edu> Date: Wed, 04 Mar 2015 14:43:41 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Christian Kujau , 19998@debbugs.gnu.org Subject: Re: bug#19998: GREP_OPTIONS alternative? References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 19998 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) On 03/03/2015 09:55 PM, Christian Kujau wrote: > what's the alternative to have > some nice grep defaults and still be portable across platforms? You can put a script like this in $HOME/bin: #! /bin/sh export PATH=/usr/bin exec grep --color=auto --devices=skip "$@" and then prepend $HOME/bin to your PATH. From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 04 20:04:17 2015 Received: (at 19998) by debbugs.gnu.org; 5 Mar 2015 01:04:17 +0000 Received: from localhost ([127.0.0.1]:35371 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YTKD3-0003zY-5s for submit@debbugs.gnu.org; Wed, 04 Mar 2015 20:04:17 -0500 Received: from trent.utfs.org ([94.185.90.103]:60941) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YTKD1-0003zG-3G for 19998@debbugs.gnu.org; Wed, 04 Mar 2015 20:04:16 -0500 Received: by trent.utfs.org (Postfix, from userid 8) id 9763E3DB4F; Thu, 5 Mar 2015 02:04:08 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on trent.utfs.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.5 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Received: from trent.utfs.org (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id 95FAC3DB05; Thu, 5 Mar 2015 02:04:07 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id 7604E3DA38; Thu, 5 Mar 2015 02:04:07 +0100 (CET) Date: Wed, 4 Mar 2015 17:04:06 -0800 (PST) From: Christian Kujau To: Paul Eggert Subject: Re: bug#19998: GREP_OPTIONS alternative? In-Reply-To: <54F78A9D.1040904@cs.ucla.edu> Message-ID: References: <54F78A9D.1040904@cs.ucla.edu> User-Agent: Alpine 2.19.4 (DEB 40 2013-11-18) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-AV-Checked: ClamAV using ClamSMTP (127.0.0.1 at Thu Mar 5 02:04:07 2015 +0100 (CET)) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19998 Cc: 19998@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Wed, 4 Mar 2015 at 14:43, Paul Eggert wrote: > You can put a script like this in $HOME/bin: > > #! /bin/sh > export PATH=/usr/bin > exec grep --color=auto --devices=skip "$@" > > and then prepend $HOME/bin to your PATH. Well, and I'd have to do this for every *grep variant, so instead of creating different aliases, I'm creating different scripts, which is an even greater change :-( Is there really no other way? I hope nobody removes PAGER, LESS or HISTCONTROL anytime soon :-\ Christian. -- BOFH excuse #88: Boss' kid fucked up the machine From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 04 21:29:10 2015 Received: (at 19998) by debbugs.gnu.org; 5 Mar 2015 02:29:10 +0000 Received: from localhost ([127.0.0.1]:35388 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YTLXC-0005xy-5K for submit@debbugs.gnu.org; Wed, 04 Mar 2015 21:29:10 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:59495) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YTLX9-0005xA-MA for 19998@debbugs.gnu.org; Wed, 04 Mar 2015 21:29:08 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 79271A60045; Wed, 4 Mar 2015 18:29:01 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hgookbcCDjQg; Wed, 4 Mar 2015 18:29:01 -0800 (PST) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 3D3AAA60007; Wed, 4 Mar 2015 18:29:01 -0800 (PST) Message-ID: <54F7BF6D.2050808@cs.ucla.edu> Date: Wed, 04 Mar 2015 18:29:01 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Christian Kujau Subject: Re: bug#19998: GREP_OPTIONS alternative? References: <54F78A9D.1040904@cs.ucla.edu> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 19998 Cc: 19998@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Christian Kujau wrote: > I'd have to do this for every *grep variant No, not if the other variants invoke 'grep'. From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 05 10:29:36 2015 Received: (at 19998) by debbugs.gnu.org; 5 Mar 2015 15:29:36 +0000 Received: from localhost ([127.0.0.1]:36133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YTXiR-00049w-HG for submit@debbugs.gnu.org; Thu, 05 Mar 2015 10:29:35 -0500 Received: from mailgw01.kcn.ne.jp ([61.86.7.208]:48648) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YTXiO-00049c-Ft for 19998@debbugs.gnu.org; Thu, 05 Mar 2015 10:29:33 -0500 Received: from mxs02-s (mailgw2.kcn.ne.jp [61.86.15.234]) by mailgw01.kcn.ne.jp (Postfix) with ESMTP id 7D69180399 for <19998@debbugs.gnu.org>; Fri, 6 Mar 2015 00:29:25 +0900 (JST) X-matriXscan-loop-detect: 5a9c25f388456c3523e1739e8b8c0203fe9ba21d Received: from mail05.kcn.ne.jp ([61.86.6.184]) by mxs02-s with ESMTP; Fri, 06 Mar 2015 00:29:24 +0900 (JST) Received: from [10.120.1.76] (i118-21-128-66.s30.a048.ap.plala.or.jp [118.21.128.66]) by mail05.kcn.ne.jp (Postfix) with ESMTPA id 80D5F7D0099; Fri, 6 Mar 2015 00:29:24 +0900 (JST) Date: Fri, 06 Mar 2015 00:29:25 +0900 From: Norihiro Tanaka To: Christian Kujau Subject: Re: bug#19998: GREP_OPTIONS alternative? In-Reply-To: References: <54F78A9D.1040904@cs.ucla.edu> Message-Id: <20150306002924.90E6.27F6AC2D@kcn.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.65.07 [ja] X-matriXscan-CTCmd-AV: Clean X-matriXscan-Action: Approve X-matriXscan: Uncategorized X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 19998 Cc: 19998@debbugs.gnu.org, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On Wed, 4 Mar 2015 17:04:06 -0800 (PST) Christian Kujau wrote: > On Wed, 4 Mar 2015 at 14:43, Paul Eggert wrote: > > You can put a script like this in $HOME/bin: > > > > #! /bin/sh > > export PATH=/usr/bin > > exec grep --color=auto --devices=skip "$@" > > > > and then prepend $HOME/bin to your PATH. > > Well, and I'd have to do this for every *grep variant, so instead of > creating different aliases, I'm creating different scripts, which is an > even greater change :-( > > Is there really no other way? > > I hope nobody removes PAGER, LESS or HISTCONTROL anytime soon :-\ > > Christian. > -- > BOFH excuse #88: > > Boss' kid fucked up the machine > > Please think to use grep -F and grep -E instead of fgrep and egrep. For others, you can use following script, or customize grep's source code and rebuild it to change default. -- mv /bin/grep /bin/grep.bin cat </bin/grep #! /bin/sh exec /bin/grep.bin --color=auto --devices=skip "$@" EOF chmod a+x /bin/grep -- -- diff -ru grep-2.21.orig/src/grep.c grep-2.21/src/grep.c --- grep-2.21.orig/src/grep.c 2014-11-09 19:00:37.000000000 +0000 +++ grep-2.21/src/grep.c 2015-03-05 15:26:59.000000000 +0000 @@ -72,7 +72,7 @@ static bool suppress_errors; /* If nonzero, use color markers. */ -static int color_option; +static int color_option = 2; /* Show only the part of a line matching the expression. */ static bool only_matching; @@ -391,7 +391,7 @@ READ_COMMAND_LINE_DEVICES, READ_DEVICES, SKIP_DEVICES - } devices = READ_COMMAND_LINE_DEVICES; + } devices = SKIP_DEVICES; static bool grepfile (int, char const *, bool, bool); static bool grepdesc (int, bool); -- From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 05 14:25:07 2015 Received: (at 19998) by debbugs.gnu.org; 5 Mar 2015 19:25:07 +0000 Received: from localhost ([127.0.0.1]:36253 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YTbOM-0003UT-Ft for submit@debbugs.gnu.org; Thu, 05 Mar 2015 14:25:07 -0500 Received: from trent.utfs.org ([94.185.90.103]:59975) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YTbOJ-0003Tt-Ug for 19998@debbugs.gnu.org; Thu, 05 Mar 2015 14:25:04 -0500 Received: by trent.utfs.org (Postfix, from userid 8) id C90B53DB4F; Thu, 5 Mar 2015 20:24:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on trent.utfs.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.5 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Received: from trent.utfs.org (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id 1DCDC3DB05; Thu, 5 Mar 2015 20:24:57 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id 013FF3DA38; Thu, 5 Mar 2015 20:24:57 +0100 (CET) Date: Thu, 5 Mar 2015 11:24:56 -0800 (PST) From: Christian Kujau To: Norihiro Tanaka Subject: Re: bug#19998: GREP_OPTIONS alternative? In-Reply-To: <20150306002924.90E6.27F6AC2D@kcn.ne.jp> Message-ID: References: <54F78A9D.1040904@cs.ucla.edu> <20150306002924.90E6.27F6AC2D@kcn.ne.jp> User-Agent: Alpine 2.19.4 (DEB 40 2013-11-18) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-AV-Checked: ClamAV using ClamSMTP (127.0.0.1 at Thu Mar 5 20:24:57 2015 +0100 (CET)) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19998 Cc: 19998@debbugs.gnu.org, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Fri, 6 Mar 2015 at 00:29, Norihiro Tanaka wrote: > Please think to use grep -F and grep -E instead of fgrep and egrep. > For others, you can use following script, or customize grep's source > code and rebuild it to change default. OK, that (and the bits below) seem to confirm that there's no simple alternative to GREP_OPTIONS and one has to make serious changes to mimic that behaviour. Oh well... Thanks for your input though. Christian. > > -- > mv /bin/grep /bin/grep.bin > cat </bin/grep > #! /bin/sh > exec /bin/grep.bin --color=auto --devices=skip "$@" > EOF > chmod a+x /bin/grep > -- > > > -- > diff -ru grep-2.21.orig/src/grep.c grep-2.21/src/grep.c > --- grep-2.21.orig/src/grep.c 2014-11-09 19:00:37.000000000 +0000 > +++ grep-2.21/src/grep.c 2015-03-05 15:26:59.000000000 +0000 > @@ -72,7 +72,7 @@ > static bool suppress_errors; > > /* If nonzero, use color markers. */ > -static int color_option; > +static int color_option = 2; > > /* Show only the part of a line matching the expression. */ > static bool only_matching; > @@ -391,7 +391,7 @@ > READ_COMMAND_LINE_DEVICES, > READ_DEVICES, > SKIP_DEVICES > - } devices = READ_COMMAND_LINE_DEVICES; > + } devices = SKIP_DEVICES; > > static bool grepfile (int, char const *, bool, bool); > static bool grepdesc (int, bool); > -- > > -- BOFH excuse #119: evil hackers from Serbia. From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 11 14:16:08 2015 Received: (at 19998-done) by debbugs.gnu.org; 11 Mar 2015 18:16:08 +0000 Received: from localhost ([127.0.0.1]:43108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVlAt-0007YV-Ql for submit@debbugs.gnu.org; Wed, 11 Mar 2015 14:16:08 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:32772) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVlAs-0007Xv-1l for 19998-done@debbugs.gnu.org; Wed, 11 Mar 2015 14:16:06 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 4A709A60038; Wed, 11 Mar 2015 11:16:00 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PDfMZ8dKHfSg; Wed, 11 Mar 2015 11:15:59 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 8F26EA6002F; Wed, 11 Mar 2015 11:15:59 -0700 (PDT) Message-ID: <5500865F.3040102@cs.ucla.edu> Date: Wed, 11 Mar 2015 11:15:59 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Christian Kujau Subject: Re: bug#19998: GREP_OPTIONS alternative? References: <54F78A9D.1040904@cs.ucla.edu> <20150306002924.90E6.27F6AC2D@kcn.ne.jp> In-Reply-To: Content-Type: multipart/mixed; boundary="------------060908060000020704060803" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 19998-done Cc: 19998-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------060908060000020704060803 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 03/05/2015 11:24 AM, Christian Kujau wrote: > that (and the bits below) seem to confirm that there's no simple > alternative to GREP_OPTIONS I don't see why the script solution is not considered 'simple'. Anyway, it's worth documenting the script alternative, so I installed the attached into the manual and am marking the bug as done. --------------060908060000020704060803 Content-Type: text/x-patch; name="0001-doc-give-a-script-wrapper-example.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-doc-give-a-script-wrapper-example.patch" >From cd5e8b1071296d930a88d60789f24abab941b81a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 11 Mar 2015 11:14:51 -0700 Subject: [PATCH] doc: give a script wrapper example * doc/grep.texi (Environment Variables): Give an example of a wrapper script, as an alternative to using GREP_OPTIONS. Fixes: bug#19998 --- doc/grep.texi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/grep.texi b/doc/grep.texi index 18a1102..e3495bb 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -838,6 +838,15 @@ explicit options. As this causes problems when writing portable scripts, this feature will be removed in a future release of @command{grep}, and @command{grep} warns if it is used. Please use an alias or script instead. +For example, if @command{grep} is in the directory @samp{/usr/bin} you +can prepend @file{$HOME/bin} to your @env{PATH} and create an +executable script @file{$HOME/bin/grep} containing the following: + +@example +#! /bin/sh +export PATH=/usr/bin +exec grep --color=auto --devices=skip "$@@" +@end example @item GREP_COLOR @vindex GREP_COLOR @r{environment variable} -- 2.1.0 --------------060908060000020704060803-- From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 11 17:12:09 2015 Received: (at 19998-done) by debbugs.gnu.org; 11 Mar 2015 21:12:09 +0000 Received: from localhost ([127.0.0.1]:43188 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVnvF-0005gw-Gg for submit@debbugs.gnu.org; Wed, 11 Mar 2015 17:12:09 -0400 Received: from trent.utfs.org ([94.185.90.103]:34295) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVnvD-0005gT-6k for 19998-done@debbugs.gnu.org; Wed, 11 Mar 2015 17:12:08 -0400 Received: by trent.utfs.org (Postfix, from userid 8) id 13FB03DBB7; Wed, 11 Mar 2015 22:12:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on trent.utfs.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.5 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from trent.utfs.org (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id E5C023DB57; Wed, 11 Mar 2015 22:11:58 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id C249D3DAC7; Wed, 11 Mar 2015 22:11:58 +0100 (CET) Date: Wed, 11 Mar 2015 14:11:58 -0700 (PDT) From: Christian Kujau To: Paul Eggert Subject: Re: bug#19998: GREP_OPTIONS alternative? In-Reply-To: <5500865F.3040102@cs.ucla.edu> Message-ID: References: <54F78A9D.1040904@cs.ucla.edu> <20150306002924.90E6.27F6AC2D@kcn.ne.jp> <5500865F.3040102@cs.ucla.edu> User-Agent: Alpine 2.19.4 (DEB 40 2013-11-18) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-AV-Checked: ClamAV using ClamSMTP (127.0.0.1 at Wed Mar 11 22:11:58 2015 +0100 (CET)) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19998-done Cc: 19998-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Wed, 11 Mar 2015 at 11:15, Paul Eggert wrote: > On 03/05/2015 11:24 AM, Christian Kujau wrote: > > that (and the bits below) seem to confirm that there's no simple > > alternative to GREP_OPTIONS > > I don't see why the script solution is not considered 'simple'. Hm, I don't understand how the script solution _can_ be considered 'simple', but maybe I haven't made it clear enough. With GREP_OPTIONS, one only had to put a single line in .profile, which was honored by all the GNU grep variants that supported GREP_OPTIONS. export GREP_OPTIONS="...." Without GREP_OPTIONS, one has to 1) Write a script for each grep variant (fgrep, zgrep, egrep, etc.) 2) put $HOME/bin in $PATH I'd consider this much more complicated, especially 1) - either write a script for eeach variant or write a single script that pays attention on how it's called and put symlinks in $HOME/bin. Also: on systems that do _not_ support these options, I cannot use this setup. To elaborate on this a bit more: I usually have a fairly static set of .dotfiles that I'd like to install in $HOME on a new machine. For instance, I'd set HISTTIMEFORMAT which is honored by newer versions of 'bash' but maybe the system does not have a bash installed and then this variable is just ignored, no harm done. Same with GREP_OPTIONS - if GNU/grep was installed, the variable would be honored, other grep implementations might choose to ignore it. If $HOME/bin/grep is really "grep --devices=skip", a the Solaris version of grep would bail with "unrecognized option". Of course, I understand the flip side of the coin: if GREP_OPTIONS gets set, maybe even system wide, shell scripts may behave differently. But that's true for every environment variable. If PATH omits /bin:/usr/bin, scripts maye behave very differently. Same for LC_ALL or or something else. Even GNU/tar has TAR_OPTIONS, so I don't really understand why GREP_OPTIONS is being dropped, just because some script broke because it didn't pay attention to environment variables. > Anyway, it's > worth documenting the script alternative, so I installed the attached into the > manual and am marking the bug as done. I didn't even expect that a mail the mailing list would open a formal bug report :-) Christian. -- BOFH excuse #277: Your Flux Capacitor has gone bad. From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 11 18:33:27 2015 Received: (at 19998-done) by debbugs.gnu.org; 11 Mar 2015 22:33:28 +0000 Received: from localhost ([127.0.0.1]:43228 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVpBv-0007r0-HT for submit@debbugs.gnu.org; Wed, 11 Mar 2015 18:33:27 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:45968) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVpBt-0007qo-Nd for 19998-done@debbugs.gnu.org; Wed, 11 Mar 2015 18:33:26 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 0E544A6004B; Wed, 11 Mar 2015 15:33:19 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9fd82BSMT1d7; Wed, 11 Mar 2015 15:33:18 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id C064EA60041; Wed, 11 Mar 2015 15:33:18 -0700 (PDT) Message-ID: <5500C2AB.5080606@cs.ucla.edu> Date: Wed, 11 Mar 2015 15:33:15 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Christian Kujau Subject: Re: bug#19998: GREP_OPTIONS alternative? References: <54F78A9D.1040904@cs.ucla.edu> <20150306002924.90E6.27F6AC2D@kcn.ne.jp> <5500865F.3040102@cs.ucla.edu> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 19998-done Cc: 19998-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Christian Kujau wrote: > Without GREP_OPTIONS, one has to > > 1) Write a script for each grep variant (fgrep, zgrep, egrep, etc.) > 2) put $HOME/bin in $PATH No, you don't need to write a script for each grep variant. You need to write a script only for 'grep'. That's because fgrep etc. invoke grep. > Even GNU/tar has TAR_OPTIONS Yes, and on my list of things to do is to remove TAR_OPTIONS as well, for the same reasons that GREP_OPTIONS should be removed. (You have been warned. :-) It's too error-prone to have fundamental utilities' behavior depend on settings of random environment variables. From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 11 18:53:45 2015 Received: (at 19998-done) by debbugs.gnu.org; 11 Mar 2015 22:53:45 +0000 Received: from localhost ([127.0.0.1]:43251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVpVZ-0008OM-A3 for submit@debbugs.gnu.org; Wed, 11 Mar 2015 18:53:45 -0400 Received: from trent.utfs.org ([94.185.90.103]:36923) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVpVX-0008O9-Cj for 19998-done@debbugs.gnu.org; Wed, 11 Mar 2015 18:53:44 -0400 Received: by trent.utfs.org (Postfix, from userid 8) id EF09D3DBB7; Wed, 11 Mar 2015 23:53:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on trent.utfs.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.5 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from trent.utfs.org (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id 76C653DB57; Wed, 11 Mar 2015 23:53:35 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id 4B27A3DAC7; Wed, 11 Mar 2015 23:53:35 +0100 (CET) Date: Wed, 11 Mar 2015 15:53:35 -0700 (PDT) From: Christian Kujau To: Paul Eggert Subject: Re: bug#19998: GREP_OPTIONS alternative? In-Reply-To: <5500C2AB.5080606@cs.ucla.edu> Message-ID: References: <54F78A9D.1040904@cs.ucla.edu> <20150306002924.90E6.27F6AC2D@kcn.ne.jp> <5500865F.3040102@cs.ucla.edu> <5500C2AB.5080606@cs.ucla.edu> User-Agent: Alpine 2.19.4 (DEB 40 2013-11-18) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-AV-Checked: ClamAV using ClamSMTP (127.0.0.1 at Wed Mar 11 23:53:35 2015 +0100 (CET)) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19998-done Cc: 19998-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Wed, 11 Mar 2015 at 15:33, Paul Eggert wrote: > > 1) Write a script for each grep variant (fgrep, zgrep, egrep, etc.) > > 2) put $HOME/bin in $PATH > > No, you don't need to write a script for each grep variant. You need to write > a script only for 'grep'. That's because fgrep etc. invoke grep. One might think so, but it doesn't work. On a Debian/Linux or a SuSE Linux system, /bin/*grep are not symlinks to /bin/grep but seperate executables. Even zgrep (a shell script) rewrites itself to /usr/bin/bin and thus $HOME/bin/grep is never called. > It's too error-prone to have fundamental utilities' behavior depend on > settings of random environment variables. Why is GREP_OPTIONS random and LESS or ZIPOPT or GZIP are not? Christian. $ cat $HOME/bin/grep #!/bin/sh export PATH=/usr/bin:/bin exec grep --line-number "$@" $ unset GREP_OPTIONS $ export PATH=$HOME/bin:$PATH $ echo hello | grep ll 1:hello $ echo hello | fgrep ll hello -- BOFH excuse #143: had to use hammer to free stuck disk drive heads. From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 11 20:58:52 2015 Received: (at 19998-done) by debbugs.gnu.org; 12 Mar 2015 00:58:52 +0000 Received: from localhost ([127.0.0.1]:43284 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVrSe-00030a-1P for submit@debbugs.gnu.org; Wed, 11 Mar 2015 20:58:52 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:51662) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVrSc-00030N-Kh for 19998-done@debbugs.gnu.org; Wed, 11 Mar 2015 20:58:51 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 3D94CA60018; Wed, 11 Mar 2015 17:58:44 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3qOsf1L7btVf; Wed, 11 Mar 2015 17:58:43 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 71E65A60016; Wed, 11 Mar 2015 17:58:43 -0700 (PDT) Message-ID: <5500E4C2.2060502@cs.ucla.edu> Date: Wed, 11 Mar 2015 17:58:42 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Christian Kujau Subject: Re: bug#19998: GREP_OPTIONS alternative? References: <54F78A9D.1040904@cs.ucla.edu> <20150306002924.90E6.27F6AC2D@kcn.ne.jp> <5500865F.3040102@cs.ucla.edu> <5500C2AB.5080606@cs.ucla.edu> In-Reply-To: Content-Type: multipart/mixed; boundary="------------020902090804010509040105" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 19998-done Cc: 19998-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------020902090804010509040105 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Christian Kujau wrote: > On a Debian/Linux or a > SuSE Linux system,/bin/*grep are not symlinks to /bin/grep but > seperate executables. On my Ubuntu 14.10 system, fgrep lives in /bin and is a separate executable (actually a shell script), but it invokes 'grep'. Likewise for Fedora 21, where fgrep lives in /usr/bin. So what you write doesn't necessarily contradict what I said. On the other hand, now that I've tested it, I see that when I type 'fgrep' Bash invokes it as '/bin/fgrep', which surprises me and which defeats the purpose of having 'fgrep' look at $0. I installed the attached patch, which should fix that. > Why is GREP_OPTIONS random and LESS or ZIPOPT or GZIP are not? For starters, none of the other variables are used by standard utilities. Admittedly some judgment is needed here. As LESS is merely a user-interface thing it's less worrisome. I don't know what ZIPOPT is. GZIP is worrisome and probably should go -- an attacker can use GZIP to cause 'gzip' to remove /etc/passwd, for example. So it looks like I should add removing GZIP to my list of things to do too.... --------------020902090804010509040105 Content-Type: text/x-patch; name="0001-egrep-fgrep-just-use-what-s-in-PATH.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-egrep-fgrep-just-use-what-s-in-PATH.patch" >From f8471e3d5d7d90de5e36068a1ddc60f3987e3bfb Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 11 Mar 2015 17:55:37 -0700 Subject: [PATCH] egrep, fgrep: just use what's in PATH * src/egrep.sh: Don't monkey with PATH; just use whatever 'grep' is in the path. This is simpler, and lets the user specify default options with a script for only grep, with no need for egrep and fgrep scripts. Fixes: bug#19998 --- src/egrep.sh | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/egrep.sh b/src/egrep.sh index 1a03d2a..6d6c15a 100644 --- a/src/egrep.sh +++ b/src/egrep.sh @@ -1,11 +1,2 @@ #!@SHELL@ -grep=grep -case $0 in - */*) - dir=${0%/*} - if test -x "$dir/@grep@"; then - PATH=$dir:$PATH - grep=@grep@ - fi;; -esac -exec $grep @option@ "$@" +exec @grep@ @option@ "$@" -- 2.1.0 --------------020902090804010509040105-- From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 12 04:05:06 2015 Received: (at 19998) by debbugs.gnu.org; 12 Mar 2015 08:05:06 +0000 Received: from localhost ([127.0.0.1]:43396 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVy77-0005FF-HT for submit@debbugs.gnu.org; Thu, 12 Mar 2015 04:05:05 -0400 Received: from mx1.riseup.net ([198.252.153.129]:34412) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YVy73-0005El-J2 for 19998@debbugs.gnu.org; Thu, 12 Mar 2015 04:05:02 -0400 Received: from berryeater.riseup.net (berryeater-pn.riseup.net [10.0.1.120]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.riseup.net (Postfix) with ESMTPS id 2D52741CE7; Thu, 12 Mar 2015 08:05:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: santiagorr) with ESMTPSA id 5B51E400B9 Received: by nomada (sSMTP sendmail emulation); Thu, 12 Mar 2015 09:04:56 +0100 Date: Thu, 12 Mar 2015 09:04:56 +0100 From: Santiago Ruano =?iso-8859-1?Q?Rinc=F3n?= To: Paul Eggert Subject: Re: bug#19998: GREP_OPTIONS alternative? Message-ID: <20150312080456.GA17630@nomada> References: <54F78A9D.1040904@cs.ucla.edu> <20150306002924.90E6.27F6AC2D@kcn.ne.jp> <5500865F.3040102@cs.ucla.edu> <5500C2AB.5080606@cs.ucla.edu> <5500E4C2.2060502@cs.ucla.edu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="gBBFr7Ir9EOA20Yy" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5500E4C2.2060502@cs.ucla.edu> User-Agent: Mutt/1.5.23 (2014-03-12) X-Virus-Scanned: clamav-milter 0.98.6 at mx1 X-Virus-Status: Clean X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19998 Cc: 19998@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi, El 11/03/15 a las 17:58, Paul Eggert escribió: ... > On the other hand, now that I've tested it, I see that when I type 'fgrep' > Bash invokes it as '/bin/fgrep', which surprises me and which defeats the > purpose of having 'fgrep' look at $0. I installed the attached patch, which > should fix that. ... Then, please consider the attached patch, to clean src/Makefile.am up. This shouldn't belong to this topic, but is there any reason to call this wrapper with a shell other than sh (I've set it to /bin/sh in Debian) Cheers, Santiago --gBBFr7Ir9EOA20Yy Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="grep-Makefile-wrapper.patch" diff --git a/src/Makefile.am b/src/Makefile.am index 5c608df..81a5027 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -47,15 +47,7 @@ EXTRA_DIST = dosbuf.c egrep.sh egrep fgrep: egrep.sh Makefile $(AM_V_GEN)grep=`echo grep | sed -e '$(transform)'` && \ case $@ in egrep) option=-E;; fgrep) option=-F;; esac && \ - shell_does_substrings='set x/y && d=$${1%/*} && test "$$d" = x' && \ - if $(SHELL) -c "$$shell_does_substrings" 2>/dev/null; then \ - edit_substring='s,X,X,'; \ - else \ - edit_substring='s,\$${0%/\*},`expr "X$$0" : '\''X\\(.*\\)/'\''`,g'; \ - fi && \ sed -e 's|[@]SHELL@|$(SHELL)|g' \ - -e "$$edit_substring" \ - -e "s|[@]grep@|$$grep|g" \ -e "s|[@]option@|$$option|g" <$(srcdir)/egrep.sh >$@-t $(AM_V_at)chmod +x $@-t $(AM_V_at)mv $@-t $@ --gBBFr7Ir9EOA20Yy-- From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 13 16:28:05 2015 Received: (at 19998-done) by debbugs.gnu.org; 13 Mar 2015 20:28:05 +0000 Received: from localhost ([127.0.0.1]:45453 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YWWBh-00049L-Ar for submit@debbugs.gnu.org; Fri, 13 Mar 2015 16:28:05 -0400 Received: from trent.utfs.org ([94.185.90.103]:49424) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YWWBf-00048m-91 for 19998-done@debbugs.gnu.org; Fri, 13 Mar 2015 16:28:03 -0400 Received: by trent.utfs.org (Postfix, from userid 8) id D80893DCDA; Fri, 13 Mar 2015 21:27:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on trent.utfs.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.5 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from trent.utfs.org (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id 690523DB2E; Fri, 13 Mar 2015 21:27:55 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id 4CBCA3DAB8; Fri, 13 Mar 2015 21:27:55 +0100 (CET) Date: Fri, 13 Mar 2015 13:27:55 -0700 (PDT) From: Christian Kujau To: Paul Eggert Subject: Re: bug#19998: GREP_OPTIONS alternative? In-Reply-To: <5500E4C2.2060502@cs.ucla.edu> Message-ID: References: <54F78A9D.1040904@cs.ucla.edu> <20150306002924.90E6.27F6AC2D@kcn.ne.jp> <5500865F.3040102@cs.ucla.edu> <5500C2AB.5080606@cs.ucla.edu> <5500E4C2.2060502@cs.ucla.edu> User-Agent: Alpine 2.19.4 (DEB 40 2013-11-18) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-AV-Checked: ClamAV using ClamSMTP (127.0.0.1 at Fri Mar 13 21:27:55 2015 +0100 (CET)) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19998-done Cc: 19998-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Wed, 11 Mar 2015 at 17:58, Paul Eggert wrote: > On my Ubuntu 14.10 system, fgrep lives in /bin and is a separate executable > (actually a shell script), but it invokes 'grep'. Likewise for Fedora 21, > where fgrep lives in /usr/bin. So what you write doesn't necessarily > contradict what I said. While it invokes "grep", it does not seem to invoke my $HOME/bin/grep, thus it will not honor the grep options set in $HOME/bin/grep. > On the other hand, now that I've tested it, I see that when I type 'fgrep' > Bash invokes it as '/bin/fgrep', which surprises me and which defeats the > purpose of having 'fgrep' look at $0. I installed the attached patch, which > should fix that. I hope that make is clear now why a helper script gets increasingly more complex if not complicated than a single environment variable. >> Why is GREP_OPTIONS random and LESS or ZIPOPT or GZIP are not? > > For starters, none of the other variables are used by standard utilities. I'd consider gzip, zip, or less pretty "standard". I'd cite more standard utilities, but I don't want to put out any more ideas here... > Admittedly some judgment is needed here. As LESS is merely a user-interface > thing it's less worrisome. I don't know what ZIPOPT is. >From zip(1): > The environment variable ZIPOPT can be used to change the default > options. So, pretty much what GREP_OPTIONS is^Wused to be. > GZIP is worrisome and probably should go -- an attacker can use GZIP to > cause 'gzip' to remove /etc/passwd, for example. So it looks like I An "attacker" can set $PATH to /tmp and do stuff too. If an attacker can modify a user's environment, all is lost anyway. > should add removing GZIP to my list of things to do too.... I was afraid you'd say something like this :-\ Christian. -- BOFH excuse #277: Your Flux Capacitor has gone bad. From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 13 22:11:39 2015 Received: (at 19998-done) by debbugs.gnu.org; 14 Mar 2015 02:11:39 +0000 Received: from localhost ([127.0.0.1]:45556 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YWbYB-0006I6-ES for submit@debbugs.gnu.org; Fri, 13 Mar 2015 22:11:39 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:48622) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YWbY9-0006Hy-HQ for 19998-done@debbugs.gnu.org; Fri, 13 Mar 2015 22:11:38 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id C74FD39E80BC; Fri, 13 Mar 2015 19:11:36 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LNTgtV6owpPY; Fri, 13 Mar 2015 19:11:36 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 6E00139E801F; Fri, 13 Mar 2015 19:11:36 -0700 (PDT) Message-ID: <550398D8.2080901@cs.ucla.edu> Date: Fri, 13 Mar 2015 19:11:36 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Christian Kujau Subject: Re: bug#19998: GREP_OPTIONS alternative? References: <54F78A9D.1040904@cs.ucla.edu> <20150306002924.90E6.27F6AC2D@kcn.ne.jp> <5500865F.3040102@cs.ucla.edu> <5500C2AB.5080606@cs.ucla.edu> <5500E4C2.2060502@cs.ucla.edu> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 19998-done Cc: 19998-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Christian Kujau wrote: > An "attacker" can set $PATH to /tmp and do stuff too. Sure, but that's well-known and standardized and it's easy (and expected) for administrative applications to sanitize PATH. The problem comes when we have lots of mysterious little environment variables any of which can wreak havoc. From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 14 00:13:25 2015 Received: (at 19998-done) by debbugs.gnu.org; 14 Mar 2015 04:13:25 +0000 Received: from localhost ([127.0.0.1]:45612 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YWdS1-0000op-8M for submit@debbugs.gnu.org; Sat, 14 Mar 2015 00:13:25 -0400 Received: from trent.utfs.org ([94.185.90.103]:60581) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YWdRz-0000of-8H for 19998-done@debbugs.gnu.org; Sat, 14 Mar 2015 00:13:23 -0400 Received: by trent.utfs.org (Postfix, from userid 8) id 1B7863DCDA; Sat, 14 Mar 2015 05:13:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on trent.utfs.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.5 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from trent.utfs.org (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id 5E3C93DB2E; Sat, 14 Mar 2015 05:13:19 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by trent.utfs.org (Postfix) with ESMTP id 33E943DAB8; Sat, 14 Mar 2015 05:13:19 +0100 (CET) Date: Fri, 13 Mar 2015 21:13:19 -0700 (PDT) From: Christian Kujau To: Paul Eggert Subject: Re: bug#19998: GREP_OPTIONS alternative? In-Reply-To: <550398D8.2080901@cs.ucla.edu> Message-ID: References: <54F78A9D.1040904@cs.ucla.edu> <20150306002924.90E6.27F6AC2D@kcn.ne.jp> <5500865F.3040102@cs.ucla.edu> <5500C2AB.5080606@cs.ucla.edu> <5500E4C2.2060502@cs.ucla.edu> <550398D8.2080901@cs.ucla.edu> User-Agent: Alpine 2.19.4 (DEB 40 2013-11-18) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-AV-Checked: ClamAV using ClamSMTP (127.0.0.1 at Sat Mar 14 05:13:19 2015 +0100 (CET)) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19998-done Cc: 19998-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Fri, 13 Mar 2015 at 19:11, Paul Eggert wrote: > > An "attacker" can set $PATH to /tmp and do stuff too. > > Sure, but that's well-known and standardized and it's easy (and expected) for > administrative applications to sanitize PATH. The problem comes when we have s/PATH/TMPDIR/ - or LD_PRELOAD or LD_LIBRARY_PATH, etc. All "well known" and "potentially dangerous" if not cared for. I relalize of course that you won't change your mind about GREP_OPTIONS, but I'm a bit surpised that such a visible change in userspace was done w/o any consideration of the users of said feature. Oh well... Christian. -- BOFH excuse #338: old inkjet cartridges emanate barium-based fumes From unknown Wed Aug 20 04:12:23 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 11 Apr 2015 11:24:05 +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