bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature request: Enable possibility of colored stderr output


From: Dale R. Worley
Subject: Re: Feature request: Enable possibility of colored stderr output
Date: Wed, 23 Sep 2020 23:05:13 -0400

A M <alex334599@gmail.com> writes:
> It would be really neat to have functionality that stderr could be 
> output in a different color compared to stdout.

It seems like the right way to implement this would be to build a
program that reads from two inputs at once and interleaves what it gets
from the two inputs, and outputs that on its stdout.  In addition, it
would ensure that text from each input was labled with the right
colorization codes (whatever that might be).  Writing that has some
complexity but is mostly careful programming.  It also involves nailing
down exactly what colorization scheme you want to use.

Then, in bash, you could execute something like:

exec >&$xxx 2>&$yyy

to redirect all future stderr and stdout into the post-processor.

The part I can't figure out is how to start and background the
postprocessor leaving its two input fd's (xxx and yyy in the above
commands) open and accessible to later bash commands.  That isn't
difficult to do with one fd; you can do something like

    exec 3> >( postprocessor )

    command >&3

I wonder if you could do something like this, using a process
substitition to a dummy "sleep" process to create an additional
connection:

    exec 3> >( sleep 60 )
    exec 4> >( postprocessor /dev/fd/3 )

    exec >&3 2>&4
    exec 3>&- 4>&-

I'll leave that question to the experts.

Dale



reply via email to

[Prev in Thread] Current Thread [Next in Thread]