HNHacker News
TopNewBestAskShowJobs

basicer

13 karma · joined September 15, 2014

submissionscomments
basicer··on Colorizing Stderr: racing pipes, and libc monkey-patching
We do!
basicer··on Colorizing Stderr: racing pipes, and libc monkey-patching
Neat! We were actually considering doing something like this with custom CSI sequences. Glad to see someone else has already picked some sensible ones.
basicer··on Colorizing Stderr: racing pipes, and libc monkey-patching
SSH only separates the streams when you don't request a PTY. For example try:

  ssh localhost -t 'echo hi 1>&2'  2>test
vs

  ssh localhost 'echo hi 1>&2'  2>test
basicer··on Colorizing Stderr: racing pipes, and libc monkey-patching
We tried something like this. Minimal was still confusing a non-trivial percentage of the time. Testing locally it was around 0.9%, but in production under docker where execution is constrained to a single core, it seemed to happen much more often.

It is really confusing to the user to have the prompt in the middle of their output.

basicer··on Colorizing Stderr: racing pipes, and libc monkey-patching
You can actually set an environmental variable with any color code you want: STDERRED_ESC_CODE. As for color codes in stderr, they work in most cases. If all the color codes are in a single write(), it will more or less be unaffected by the extra red and reset color codes that get stuck on either end.
basicer··on Colorizing Stderr: racing pipes, and libc monkey-patching
Not sure what update-initramfs does exactly, but if you ever close(2) your going to be in a world of hurt, because the next file you open is going to have a bunch of junk written to it.

At repl.it we don't put it in our .bashrc or anything like that, we call the wrapper program manually when we launch the user's binary.

basicer··on Colorizing Stderr: racing pipes, and libc monkey-patching
Not normally, no. The file descriptors sort of act like pointers. During normal execution in a pty, stdrr and stdout both point to the same device with the same buffer. Nothing is handling the order because there is only one buffer being written to.