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 1M2Qnx-0008P6-4I for garchives@archives.gentoo.org; Fri, 08 May 2009 14:12:01 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F1E69E03AA; Fri, 8 May 2009 14:11:58 +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 AD73EE03AA for ; Fri, 8 May 2009 14:11:58 +0000 (UTC) Received: by ewy9 with SMTP id 9so1871761ewy.34 for ; Fri, 08 May 2009 07:11:58 -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=zsil02Mt8n8+a8i6A7ECeMr/O495689ylbrH20cTlZs=; b=nsjEzjigOFvXrty8b05ZYsUS9Qpiwizt+HSoNs2o0bHPp/kAjr0nq/PNU61QLi1iTY RwcohzHhZLiRz2f6GxRxV/eosDsNzcIrqbRgPuKZFEtwOKZ3I/0zLg3K7N6ce/jy/RCD 7T8D4gz7prchAtBAskeKcYw5RBxgqMFpW1KXA= 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=LaVmsIevnfvcf6N2hfifyOlZ7QceeB8fKH57rlGqgp0Pom4tAAyf0DKkccG5o/dUO5 2S9mbE0a+wFJHqEcIlR1vs6zGG+UVpzUtDJaNfiamm76URTrGhRWC3tBWasfoyMlizI6 FbnPsX2H7gDGDyPwAM0a34HWFhKF/ZXBUbxQs= Received: by 10.210.109.19 with SMTP id h19mr1568815ebc.60.1241791918138; Fri, 08 May 2009 07:11:58 -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 10sm1578225eyd.22.2009.05.08.07.11.56 (version=SSLv3 cipher=RC4-MD5); Fri, 08 May 2009 07:11:57 -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:10:20 +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> <20090508200114.5edbc580@coercion> In-Reply-To: <20090508200114.5edbc580@coercion> 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: <200905081610.20300.alan.mckinnon@gmail.com> X-Archives-Salt: d6b2c782-50a9-4f6d-977d-09cc8fb7874d X-Archives-Hash: d46652ed776b0b71dfc40890770e42cf 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 -- alan dot mckinnon at gmail dot com