Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: coloring STDERR to terminal
- X-seq: zsh-users 7658
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: coloring STDERR to terminal
- Date: Fri, 2 Jul 2004 14:42:59 +0200
- In-reply-to: <Pine.LNX.4.60.0407011645450.16728@xxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20040627190433.Q27888@willy_wonka> <Pine.LNX.4.60.0406280815130.19831@xxxxxxxxxxxxxxxxxx> <20040629160826.GL2033@xxxxxxxxxxxxx> <Pine.LNX.4.60.0406291002300.31134@xxxxxxxxxxxxxxxxxx> <20040630070902.GO2033@xxxxxxxxxxxxx> <Pine.LNX.4.60.0406300311020.5600@xxxxxxxxxxxxxxxxxx> <20040630114341.GR2033@xxxxxxxxxxxxx> <Pine.LNX.4.60.0406300906100.5600@xxxxxxxxxxxxxxxxxx> <20040701181459.GF2033@xxxxxxxxxxxxx> <Pine.LNX.4.60.0407011645450.16728@xxxxxxxxxxxxxxxxxx>
- Sender: Vincent Lefevre <vincent@xxxxxxxxxx>
On 2004-07-01 17:11:08 -0700, Bart Schaefer wrote:
> So I'm forced to conclude that there really is no way to avoid the
> race condition that you originally complained about; my first
> solution is as good as it gets. You might get close if you used
> "read -t 1 ..." to make the parent shell sleep so the kernel can
> schedule the coprocess first, but then you'd have an annoying
> 1-second delay on almost every prompt. Sorry.
I have a better solution. stderr is redirected with
exec 2>>(while read line; do
print '\e[91m'${(q)line}'\e[0m' > /dev/tty; done &)
as you suggested (this avoids the coprocess in the jobs table).
Now, in precmd(), adding the following line solves the problem:
sleep 0
Of course, this won't completely avoid the race condition, but it
improves things in pratice. I assume that this forces the scheduler
to switch to another process, and in practice, the coprocess is
scheduled before precmd() is resumed.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% validated (X)HTML - Acorn / RISC OS / ARM, free software, YP17,
Championnat International des Jeux Mathématiques et Logiques, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
Messages sorted by:
Reverse Date,
Date,
Thread,
Author