[Top][All Lists]

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

Re: Feature request: Enable possibility of colored stderr output

From: Greg Wooledge
Subject: Re: Feature request: Enable possibility of colored stderr output
Date: Mon, 14 Sep 2020 08:38:31 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Sun, Sep 13, 2020 at 11:59:45AM +0200, A M wrote:
> Feature request: Enable possibility of colored stderr output.

Not possible.  Output does not "pass through" bash on the way to the
terminal.  Bash is like a plumber or a switchboard operator.  Bash just
screws all the pipes together, or plugs the wires into the holes, and
then stands back and lets the water flow, or the people talk to each

When you run a command like

foo 2>&1 | bar

bash sets up a pipe, and then forks two subshells, and connects the
stdout of the "left" side to the pipe's input hole, and connects the
stdin of the "right" side to the pipe's output hole.

Then, on the "left" side, bash closes stderr and then reopens it as a
duplicate of stdout.

Finally, each child bash executes its command, while the parent waits
for them to be finished.

The handling of stdout or stderr is done by foo and by bar.  It's outside
of bash's control.

> Below are links to some discussions/articles on stderr colorization, I
> include them as examples of the interest/demand for this functionality:
> https://stackoverflow.com/questions/6841143/how-to-set-font-color-for-stdout-and-stderr

If you like any of the hacks presented in this discussion, go ahead and
use them.  Note that they *are* hacks, truly, and they only give you
something that could be called "close enough" in certain cases.

I did not open your other links.  I'm guessing they're more of the same.

reply via email to

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