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 1M2UVi-0003ZK-22 for garchives@archives.gentoo.org; Fri, 08 May 2009 18:09:26 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 26389E050E; Fri, 8 May 2009 18:08:49 +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 D80D3E050E for ; Fri, 8 May 2009 18:08:48 +0000 (UTC) Received: by ewy9 with SMTP id 9so2023356ewy.34 for ; Fri, 08 May 2009 11:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=K1QBXwC9I2zD3sOy6onDcna9LJPhuu7QK8O9xLV3YkA=; b=nFLKy+fTX6EsVp3HWnjrqaA5i79Pcpxq/akFdaFVNfsA5bYoTElOiBXV5gyr07/7F9 P5Vg71F3AXlzoK/nerkpHodmzwRdTATHxxYWTgi+j1Va1+NM60M6GZJoiWWQEf9PTyoc asTxWoJL8H4if1VLsmaUYxLsLY66UngOKeFP8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=W80AuDpmUBvdEPsorWAIc04VU08UYpGey29uRPJpL/yUWbn3YWsoQgYlYhp1Hwd7g3 0aUigFJvjsBUJAjG3MCb08BmJPo29K7FLMMB+qkBQoQVq6hryR5HQAHW196I5O/B/lUc tY6d+v+CS5qGhNbQlhEl1WmyPpPYG3JEEMLzA= Received: by 10.216.1.77 with SMTP id 55mr1698567wec.111.1241806128245; Fri, 08 May 2009 11:08:48 -0700 (PDT) Received: from localhost (92.40.15.222.sub.mbb.three.co.uk [92.40.15.222]) by mx.google.com with ESMTPS id 24sm2078201eyx.13.2009.05.08.11.08.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 08 May 2009 11:08:46 -0700 (PDT) Date: Fri, 8 May 2009 19:08:40 +0100 From: James Rowe To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] 'if echo hello' in .bashrc Message-ID: <20090508180840.GA25880@ukfsn.org> References: <742F0C43-196E-465B-9991-3DFF1C655803@stellar.eclipse.co.uk> <20090508200114.5edbc580@coercion> <200905081610.20300.alan.mckinnon@gmail.com> <4A045C2F.90809@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: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/04w6evG8XlLl3ft" Content-Disposition: inline In-Reply-To: <4A045C2F.90809@gmx.net> User-Agent: Mutt/1.5.19 (2009-01-05) X-Archives-Salt: 0ae36653-f43f-4f9d-ab97-25be826ea264 X-Archives-Hash: de88a02bffb20132659abf7e97eff49d --/04w6evG8XlLl3ft Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Carlos Hendson (skyclan@gmx.net) wrote: > [1] The reason an error message is shown here is because it's bash > that's reporting the broken pipe error. Grep's error message was > redirected to /dev/null, which was: >=20 > grep: unrecognized option '--unsupported' > Usage: grep [OPTION]... PATTERN [FILE]... > Try `grep --help' for more information. >=20 > So even when the system doesn't support --color, that original code will > pollute the screen with bash's error message. SIGPIPE behaviour depends on the shell, how it was built and its configuration so won't always receive an error. The point of this mail however is that there is still a way around it, just call the commands within a subshell. Compare: $ (echo hello | grep --colour l >/dev/null 2>&1) && echo colour support colour support $ (echo hello | grep --broken_arg l >/dev/null 2>&1) && echo broken_arg s= upport with the original non-subshell'd version: $ echo hello | grep --broken_arg l >/dev/null 2>&1 && echo broken_arg sup= port -bash: echo: write error: Broken pipe Thanks, James --/04w6evG8XlLl3ft Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (GNU/Linux) iEYEARECAAYFAkoEdSgACgkQotN5XLOa4B5/JgCfSIM2Wzt8r1tWYWF0NioLOuxc XGQAn31yHgjIuKmTqK/AuwFuwf1gI9BV =yIQl -----END PGP SIGNATURE----- --/04w6evG8XlLl3ft--