Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: stdbuf -o0 -i0 via a Zsh native interface?
- X-seq: zsh-workers 51809
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: stdbuf -o0 -i0 via a Zsh native interface?
- Date: Tue, 30 May 2023 12:17:58 +0100 (BST)
- Archived-at: <https://zsh.org/workers/51809>
- Importance: Normal
- In-reply-to: <CAH+w=7ZgA=80EP5peb6sO330hj2tY58LCJ=+7Lcr464L1A-JnQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAKc7PVAh95GL_kx1FiACaexEHsK8PVLrJ+T4KxnKTZr=5KDXMw@mail.gmail.com> <1297534493.4668003.1685024167868@mail.virginmedia.com> <CAH+w=7ZgA=80EP5peb6sO330hj2tY58LCJ=+7Lcr464L1A-JnQ@mail.gmail.com>
> 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"))) {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author