Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: stdbuf -o0 -i0 via a Zsh native interface?



On Fri, May 26, 2023 at 11:24 AM Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
>
> I've took a look, and it seems to be easy:
> 1. Export LD_PRELOAD=/usr/lib/zsh/5.7/libzstdbuf.so
> - https://github.com/coreutils/coreutils/blob/master/src/stdbuf.c#L196
> - https://github.com/coreutils/coreutils/blob/master/src/stdbuf.c#L259
> 2. Provide stdbuf function in libzstdbuf.so:
> - https://github.com/coreutils/coreutils/blob/master/src/libstdbuf.c#L139
>
> Seems fairly simple…

This won't work reliably. E.g., it may not work on binaries that are
linked against a different libc. A more reliable solution for your
problem is something like `unbuffer` from `expect`. This tool creates
a TTY and takes advantage of the convention that stdout to TTY is not
buffered. Better yet, you can do this with zpty without external
tools.

Roman.




Messages sorted by: Reverse Date, Date, Thread, Author