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 1M2RRW-0006Cd-NK for garchives@archives.gentoo.org; Fri, 08 May 2009 14:52:54 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E5D6EE03F6; Fri, 8 May 2009 14:52:52 +0000 (UTC) Received: from mail-ew0-f165.google.com (mail-ew0-f165.google.com [209.85.219.165]) by pigeon.gentoo.org (Postfix) with ESMTP id 91D63E03F6 for ; Fri, 8 May 2009 14:52:52 +0000 (UTC) Received: by ewy9 with SMTP id 9so1895855ewy.34 for ; Fri, 08 May 2009 07:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:references:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:message-id; bh=RMXMT4Z4XBIKj+7Dx0oME+KCSt3pEbfPpsYVR5coQiE=; b=NZwgJG+84ggrXtWHinFyhhh6uqjabuS7v6k6wODZbIUXDVFohBLEjhYj59Y4PD1CzT va+aMZSLzHL+gDtwYPVPJ5ogiT6q5CPCCQFfgvRdDwKId8S+QGTztVekbhCg7GsLB99D BuHv7sY4O5M2CJch5svJ1rcK4uyEcR1/5U2gk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:references:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :message-id; b=D2Fbmcjxyn/Ku8JI18CXBaJV/21cKA5ZwIfkUhHU4chSH72jcCiTDFHMGTnPX5VcSE /yFu95IG6fnm1hOz7INzP5/WWCZJLACI2IEtY9ed5o4n8N9pUyTBxLJj1Ba+K0JjBNe0 0eKQN6B77NDcYwsT7WFGEIVtepOQ0uleWhCk4= Received: by 10.210.27.14 with SMTP id a14mr787342eba.86.1241794368765; Fri, 08 May 2009 07:52:48 -0700 (PDT) Received: from nazgul.localnet (196-210-140-95-rrdg-esr-2.dynamic.isadsl.co.za [196.210.140.95]) by mx.google.com with ESMTPS id 10sm1666074eyz.31.2009.05.08.07.52.47 (version=SSLv3 cipher=RC4-MD5); Fri, 08 May 2009 07:52:48 -0700 (PDT) From: Alan McKinnon To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] 'if echo hello' in .bashrc Date: Fri, 8 May 2009 16:51:14 +0200 User-Agent: KMail/1.11.2 (Linux/2.6.29-gentoo-r1; KDE/4.2.2; x86_64; ; ) References: <742F0C43-196E-465B-9991-3DFF1C655803@stellar.eclipse.co.uk> <200905081610.20300.alan.mckinnon@gmail.com> <200905081659.19936.shrdlu@unlimitedmail.org> In-Reply-To: <200905081659.19936.shrdlu@unlimitedmail.org> 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: <200905081651.14777.alan.mckinnon@gmail.com> X-Archives-Salt: 1aca574b-5686-4531-8103-35a8c7d67e32 X-Archives-Hash: 050889aa5adfdd79768e45a606e034f4 On Friday 08 May 2009 16:59:19 Etaoin Shrdlu wrote: > 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. which is the desired effect. It causes the if to be false and the grep options are not enabled (as they are not supported) -- alan dot mckinnon at gmail dot com