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

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



The problem with unbuffer is that it doesn't work… It's just a simple
Tcl script which aims at providing .dev.tty via a high level Tcl
calls, which however turns out to work like:
- catch some output ~500 lines and output it,
- catch everything else and output it at the end.

Proof: https://asciinema.org/a/FrONqnnrdjHLn6Lx2xhMZBNIz

On Tue, 30 May 2023 at 11:18, Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
>
> > On 25/05/2023 19:35 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> > On Thu, May 25, 2023 at 7:16 AM Peter Stephenson
> > <p.w.stephenson@xxxxxxxxxxxx> wrote:
> > >
> > > > On 25/05/2023 12:21 Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
> > > > However, this is sub-optimal solution because I have to hideously
> > > > prepend the stdbuf command before each user CMD, meaning that entering
> > > > builtin commands will not work (e.g.: `stdbuf -i0 -o0 print smthg`).
> > > >
> > > > I wonder if the infamous buffering problem, solved by the hacky
> > > > ld-preload stdbuf program could be fixed on the level of Zsh?
> > >
> > > Something like this?  It looks like a good fit for zsystem.
> >
> > That's a start, but it doesn't solve Sebastian's problem of having to
> > hack the stdbuf prefix into the command string for external commands.
> >
> > We'd need something akin to the STTY parameter to specify a prefix for
> > external commands.  That might have its own security concerns.
>
> Yes, so in fact Sebastian's got the bit I originally added covered with
> external commands already; they don't need to be built into the shell,
> just executed appropriately.
>
> Can't we simply add a hook at the point where STTY is used?  What
> this doesn't do is the equivalent sanity after the event --- in that
> case triggering TTY restoration if we detect a case where it might have
> been messed up. ut that should be less important here as the changes
> affect the exec'd command's environment, not the whole tty.
>
> Probably would need carefully documenting as to limitations, but
> a little simple IO manipulation ought to be OK.
>
> pws
>
> diff --git a/Src/exec.c b/Src/exec.c
> index 8f9d5a885..af33397f4 100644
> --- a/Src/exec.c
> +++ b/Src/exec.c
> @@ -741,6 +741,8 @@ execute(LinkList args, int flags, int defpath)
>         zsfree(s);
>      }
>
> +    callhookfunc("zshexternal", NULL, 1, NULL);
> +
>      /* If ARGV0 is in the commands environment, we use *
>       * that as argv[0] for this external command       */
>      if (unset(RESTRICTED) && (z = zgetenv("ARGV0"))) {
>


-- 
Best regards,
Sebastian Gniazdowski




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