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 1M2RVi-000737-Rg for garchives@archives.gentoo.org; Fri, 08 May 2009 14:57:15 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 589C8E049F; Fri, 8 May 2009 14:57:13 +0000 (UTC) Received: from mail.caf.com.tr (mail.caf.com.tr [88.250.85.68]) by pigeon.gentoo.org (Postfix) with ESMTP id E9C86E049F for ; Fri, 8 May 2009 14:57:12 +0000 (UTC) Received: from localhost (sunny.caf.com.tr [127.0.0.1]) by mail.caf.com.tr (Postfix) with ESMTP id 6260439E36D for ; Fri, 8 May 2009 14:57:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=caf.com.tr; h= content-transfer-encoding:content-type:in-reply-to:references :subject:mime-version:user-agent:from:date:message-id:received :received:x-virus-scanned; s=originating; t=1241794629; bh=pUKPC bWT1oHULCKMi+kVK/YYzLo+7ELzsmb6rB8p9qM=; b=XJ6j73MojW974uWhK2Iwc Mf0X1NshHfcHPgg71msuHv8pxFzfILEadg5cccpWqpxwsjrAXhn9E7DdHTABVFvy LoZfLagohmUAgjwDnUVF2aqhM8SRCNkQbmihHvPZGXrj2w5c5S7Lwqx2CI1Ifb80 JP3JXKMEITH2Y0sl5vU7Ks= X-Virus-Scanned: amavisd-new at caf.com.tr Received: from mail.caf.com.tr ([127.0.0.1]) by localhost (sunny.caf.com.tr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jUcCSDgiUWrG for ; Fri, 8 May 2009 14:57:09 +0000 (UTC) Received: from [10.0.0.15] (unknown [10.0.0.15]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: eray.aslan@zeplin.net) by mail.caf.com.tr (Postfix) with ESMTPSA id 9026E39E350 for ; Fri, 8 May 2009 14:57:09 +0000 (UTC) Message-ID: <4A044845.7020306@caf.com.tr> Date: Fri, 08 May 2009 17:57:09 +0300 From: Eray Aslan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.0 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 To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] 'if echo hello' in .bashrc 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> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Archives-Salt: 90c1d272-5eb7-4fe9-aca5-e658f75cba32 X-Archives-Hash: 09e4cfb5aaa2632d2ef7dd50493a4def On 08.05.2009 17:10, Alan McKinnon wrote: >>> 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 No. We do not want any output from echo|grep. We just want the exit code so that the following export statement gets executed iff grep returns with no errors. -- Eray