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 1M2RK3-0005Sp-05 for garchives@archives.gentoo.org; Fri, 08 May 2009 14:45:11 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3B635E03FD; Fri, 8 May 2009 14:44:39 +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 EBFEDE03FD for ; Fri, 8 May 2009 14:44:38 +0000 (UTC) Received: by ewy9 with SMTP id 9so1890964ewy.34 for ; Fri, 08 May 2009 07:44:38 -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=iYkZ7XqQpsY8bILuFG7ihrWf/NWFsdyzlRQXKj8iXn8=; b=JVFNulwuk+imq5m5fB9Xcc1XPOruHqqrCf+lhGwuaZKmnrfyDCbr1sYvr9Vc/jbb0J L7ZLJvuBpiWkbEq/8dsUdKVg2dGTXJD57VFXJ+RYCJvAX+yq8SKNpEkqW/ASQAIuiIb7 Kkb+IsBUh7o6R0bWw7RlVRIbb4Q7AUbEgoIiM= 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=XhqBk4Jv1w+odpsrsczaFRLY8VKdcrz0berSkRSMP63WW3O0D5jawNMb9+Hg6p78sW O5E6xc90UA/VAN6fUoyDx/mq5BPZAtUPK4yDD9bpP56SmRRUrnypuqdYTqdotNiJkE0S DwH3Tg8HuQlQ+ukJsn/E3luZPKSE9FM1wS2qA= Received: by 10.216.13.209 with SMTP id b59mr1619375web.44.1241793878335; Fri, 08 May 2009 07:44:38 -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 28sm1659105eye.6.2009.05.08.07.44.37 (version=SSLv3 cipher=RC4-MD5); Fri, 08 May 2009 07:44:37 -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:43:03 +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> <200905081638.30925.mcr76@gmx.net> In-Reply-To: <200905081638.30925.mcr76@gmx.net> 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: <200905081643.03943.alan.mckinnon@gmail.com> X-Archives-Salt: 5b3e5a22-111f-4e92-88eb-b1475e49c359 X-Archives-Hash: 64dbc85263f6ba86cc289fff3826c1e8 On Friday 08 May 2009 16:38:30 Christian wrote: > Hi Alan, > > Am Freitag, 8. Mai 2009 schrieb Alan McKinnon: > > > 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. > > is this really right? > > The result of > > if echo hello|grep --Acolor=auto l >/dev/null 2>&1; then echo hallo; fi > > is nothing. Which is equal to ), which in shell terms is true Yes, it's the opposite to other languages. Yes, it really should be that way. The return value of successful process is by convention 0, which therefore is evaluated as true. Non-zero is false > So the if clause is false although I pieped STDERR to > /dev/null. > > > 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 > > grep writes to STDERR if an error is occured. > > The result of > > if echo hello|grep --Acolor=auto l >/dev/null ; then echo hallo; fi ^ What's this? I didn't type it. -- alan dot mckinnon at gmail dot com