From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13016 invoked from network); 29 Jun 2004 15:44:50 -0000 Received: from odin.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.85) by ns1.primenet.com.au with SMTP; 29 Jun 2004 15:44:50 -0000 Received: (qmail 30910 invoked from network); 29 Jun 2004 16:55:05 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 29 Jun 2004 16:55:05 -0000 Received: (qmail 20042 invoked by alias); 29 Jun 2004 15:44:03 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7615 Received: (qmail 20032 invoked from network); 29 Jun 2004 15:44:02 -0000 Received: from odin.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.85) by sunsite.dk with SMTP; 29 Jun 2004 15:44:02 -0000 Received: (qmail 29984 invoked from network); 29 Jun 2004 16:54:44 -0000 Received: from unknown (HELO moonbase.zanshin.com) (@167.160.213.139) by a.mx.sunsite.dk with SMTP; 29 Jun 2004 16:54:33 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.12.11/8.12.11) with ESMTP id i5TFho2U009367 for ; Tue, 29 Jun 2004 08:43:50 -0700 Date: Tue, 29 Jun 2004 08:43:50 -0700 (PDT) From: Bart Schaefer Reply-To: zsh-users@sunsite.dk To: zsh-users@sunsite.dk Subject: Re: coloring STDERR to terminal In-Reply-To: <20040627190433.Q27888@willy_wonka> Message-ID: References: <20040627190433.Q27888@willy_wonka> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 On Sun, 27 Jun 2004, Atom 'Smasher' wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > i'm not sure if this is possible without patching some sources, but here's > what i want to do... every time STDERR is directed to a terminal, i want to > filter it through _something_like_ this: > awk '{print "^[[91m"$0"^[[0m"}' This sort of thing is the reason that zsh's coprocess hangs around after its input and output are closed, rather than exiting the way ksh coprocs do. Assuming you're not using the coprocess for anything else (hardly anyone does) you can do this: coproc while read line; print '\e[91m'${(q)line}'\e[0m' > /dev/tty exec 2>&p (Oh, that also assumes that the "shortloops" option is set. Insert a "do" and end with ";done" if you don't have that setopt.) It's better to use a zsh while-loop than something like awk because most filter programs will wait for a full input buffer before processing and for a full output buffer before printing, but here you want each line to be processed and printed immediately.