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

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



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…

On Fri, 26 May 2023 at 02:17, Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
>
> On Thu, 25 May 2023 at 21:21, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > Use with great caution, but to test the concept:
> >
> > TRAPDEBUG() { setopt err_exit; stdbuf -o0 -i0 ${(z)ZSH_DEBUG_CMD} }
>
> Interesting, I've never touched debug trap, this gives me a glimpse of
> how it is working.
>
> And as for the topic in general, I've had a moment of understanding
> that what's needed is basically: a `stdbuf` command that's *built-in*,
> and this comes down  to your idea of `STTY=… my-cmd` -like
> inline-export variable, which is a nicer, more integrated version of a
> stdbuf-clone builtin (and could be made non-only-inline-export, to set
> once and forget). Now, who has time to look at stdbuf.c? :) To grasp
> what the LD-trick used there is?
>
> --
> Best regards,
> Sebastian Gniazdowski



-- 
Best regards,
Sebastian Gniazdowski




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