public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: James Rowe <jnrowe@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] 'if echo hello' in .bashrc
Date: Fri, 8 May 2009 19:08:40 +0100	[thread overview]
Message-ID: <20090508180840.GA25880@ukfsn.org> (raw)
In-Reply-To: <4A045C2F.90809@gmx.net>

[-- Attachment #1: Type: text/plain, Size: 1104 bytes --]

* 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:
> 
> grep: unrecognized option '--unsupported'
> Usage: grep [OPTION]... PATTERN [FILE]...
> Try `grep --help' for more information.
> 
> 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 support

with the original non-subshell'd version:

  $ echo hello | grep --broken_arg l >/dev/null 2>&1 && echo broken_arg support
  -bash: echo: write error: Broken pipe

Thanks,

James


[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2009-05-08 18:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-08 13:38 [gentoo-user] 'if echo hello' in .bashrc Stroller
2009-05-08 14:01 ` Mike Kazantsev
2009-05-08 14:09   ` Stroller
2009-05-08 14:10   ` Alan McKinnon
2009-05-08 14:38     ` Christian
2009-05-08 14:43       ` Alan McKinnon
2009-05-08 14:57     ` Eray Aslan
2009-05-08 14:59     ` Etaoin Shrdlu
2009-05-08 14:51       ` Alan McKinnon
2009-05-08 15:13         ` Etaoin Shrdlu
2009-05-08 16:22     ` Carlos Hendson
2009-05-08 18:08       ` James Rowe [this message]
2009-05-08 18:05     ` Mike Kazantsev
2009-05-09 10:15 ` Stroller
2009-05-09 10:41   ` Etaoin Shrdlu
2009-05-09 10:43     ` Stroller
2009-05-09 11:13       ` Etaoin Shrdlu
2009-05-09 14:38     ` Joerg Schilling
2009-05-09 11:38   ` Mike Kazantsev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090508180840.GA25880@ukfsn.org \
    --to=jnrowe@gmail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox