zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: stdbuf -o0 -i0 via a Zsh native interface?
Date: Tue, 30 May 2023 12:17:58 +0100 (BST)	[thread overview]
Message-ID: <833370431.820192.1685445478652@mail.virginmedia.com> (raw)
In-Reply-To: <CAH+w=7ZgA=80EP5peb6sO330hj2tY58LCJ=+7Lcr464L1A-JnQ@mail.gmail.com>

> On 25/05/2023 19:35 Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Thu, May 25, 2023 at 7:16 AM Peter Stephenson
> <p.w.stephenson@ntlworld.com> wrote:
> >
> > > On 25/05/2023 12:21 Sebastian Gniazdowski <sgniazdowski@gmail.com> 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"))) {


  parent reply	other threads:[~2023-05-30 11:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25 11:21 Sebastian Gniazdowski
2023-05-25 14:16 ` Peter Stephenson
2023-05-25 18:35   ` Bart Schaefer
2023-05-25 19:02     ` Sebastian Gniazdowski
2023-05-25 19:09       ` Bart Schaefer
2023-05-25 19:28         ` Sebastian Gniazdowski
2023-05-25 21:21           ` Bart Schaefer
2023-05-26  2:17             ` Sebastian Gniazdowski
2023-05-26 10:23               ` Sebastian Gniazdowski
2023-05-26  9:30                 ` Roman Perepelitsa
2023-05-26 20:52                   ` Bart Schaefer
2023-05-30 11:17     ` Peter Stephenson [this message]
2023-05-31 12:38       ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=833370431.820192.1685445478652@mail.virginmedia.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).