From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1M2RLt-0005lR-55 for garchives@archives.gentoo.org; Fri, 08 May 2009 14:47:05 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B0D90E046E; Fri, 8 May 2009 14:47:03 +0000 (UTC) Received: from dcnode-01.unlimitedmail.net (smtp.unlimitedmail.net [94.127.184.242]) by pigeon.gentoo.org (Postfix) with ESMTP id 4EB54E046E for ; Fri, 8 May 2009 14:47:03 +0000 (UTC) Received: from ppp.zz ([137.204.208.98]) (authenticated bits=0) by dcnode-01.unlimitedmail.net (8.14.3/8.14.3) with ESMTP id n48Ekqaj029747 for ; Fri, 8 May 2009 16:46:52 +0200 From: Etaoin Shrdlu To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] 'if echo hello' in .bashrc Date: Fri, 8 May 2009 16:59:19 +0200 User-Agent: KMail/1.9.9 References: <742F0C43-196E-465B-9991-3DFF1C655803@stellar.eclipse.co.uk> <20090508200114.5edbc580@coercion> <200905081610.20300.alan.mckinnon@gmail.com> In-Reply-To: <200905081610.20300.alan.mckinnon@gmail.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200905081659.19936.shrdlu@unlimitedmail.org> X-UnlimitedMail-MailScanner-From: shrdlu@unlimitedmail.org X-Spam-Status: No X-Archives-Salt: 01067e00-e9f3-4546-a80d-1e85082f963c X-Archives-Hash: bfacdbb287a2a67148e5e8ab07ae78c7 On Friday 8 May 2009, 16:10, Alan McKinnon wrote: > On Friday 08 May 2009 16:01:14 Mike Kazantsev wrote: > > On Fri, 8 May 2009 14:38:58 +0100 > > > > Stroller wrote: > > > To find the part to which I refer you'll need to scroll down about > > > halfway through that page to "Colorize grep"; the author advises > > > adding: > > > > > > if echo hello|grep --color=auto l >/dev/null 2>&1; then > > > export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32' > > > fi > > > > > > to ~/.bashrc > > > > > > Why does he echo hello, please? > > > > Some greps (like BSD one) might not support '--color' option, so > > "echo hello|grep --color=auto l" will return error code, skipping if > > clause, and won't break grep operation by adding an unsupported > > option. > > except that STDERR is combined with STDOUT and sent to /dev/null so > the script will never get it, the if is always true and the entire > check is redundant. Better would be > > if echo hello|grep --color=auto l >/dev/null ; then That will output an uncaptured error message if --color is not supported.