[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bash-bug
Subject:    Re: bash process substitution weird behavior
From:       Greg Wooledge <wooledg () eeg ! ccf ! org>
Date:       2015-12-08 14:38:30
Message-ID: 20151208143830.GC27325 () eeg ! ccf ! org
[Download RAW message or body]

On Tue, Dec 08, 2015 at 09:03:08PM +0900, Hyunho Cho wrote:
> # result is in red-colored after external date command output
> # i think there must be no red-colored because { echo 111; date; echo 222 ;} only \
> direct to stdout 
> BASH$ { echo 111; date; echo 222 ;} 2> >( echo -en "\e[01;31m" >&2; read line; echo \
> "$line" >&2; echo -en "\e[0m" >&2 ) 
> 111                                                   # white colored
> Tue Dec  8 20:33:33 KST 2015       # red colored
> 222                                                   # red colored

What you have here is a race condition.

You are launching a background process (echo -en ...) which writes to
the shell's stderr, then tries to read from stdin, then writes some
more stuff to the shell's stderr.

While that background job is running, you write various lines to the
shell's stdout.

The order of the arrival of the output of the background job (echo -en)
and the output of the foreground job (echo 111) is not predictable.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic