Zsh Mailing List Archive
Messages sorted by:
Re: coloring STDERR to terminal
- X-seq: zsh-users 7656
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: coloring STDERR to terminal
- Date: Thu, 1 Jul 2004 17:11:08 -0700 (PDT)
- In-reply-to: <20040701181459.GF2033@xxxxxxxxxxxxx>
- 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>
- Reply-to: zsh-users@xxxxxxxxxx
On Thu, 1 Jul 2004, Vincent Lefevre wrote:
> I don't understand why it will block. The line you gave was:
> while read -t -p -k 1; do :; done
Ah. You're right; I had only a half-formed thought, there.
I originally wrote (before sending my message, i.e. during the editing
process) "read -p -k 1" (no loop), implying always read one byte from the
coprocess. But in re-reading I realized that blocks forever when there is
no stderr for the coproc to colorize. So I changed it to the "while"
loop, which would do nothing if the coprocess produced no output, and read
the byte otherwise. But I failed to notice that this also means it does
nothing if the coproc has not written the byte *yet*, which is what you
were pointing out.
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.
Messages sorted by: