From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3596 invoked from network); 31 May 2023 12:39:27 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 31 May 2023 12:39:27 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1685536767; b=S/7kV0p5fYvphyDHx3tW/cidaYeI2NkWTjC+fRYCzBlhaMGJCimCuiO1QsgAhoiUB02STtSzzy KKFBV0gNG0DvIaQzdTKQUaz54aQajP1T1Abj+49mA6W9D7l9VMurBU0/8zMApuPXNc1G3nHPve uiGO9zyKy7YietiBn0DMHUwpsracf4lU5tMkKj5D2KCxg4FI1zMpv+02xrW4VlomDRSG9xl/E0 gUGq1ytPvu1w9rN3kGjJo2AyTBkSqx2KBu2t4ogGnSVTf1J5+uWStgy9lIqelXaUuEoSMw3GuV siovBCprmzgQqi90abOFFGiBfIUOT/W/6wlZq/jvJaLYWA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f175.google.com) smtp.remote-ip=209.85.208.175; dkim=pass header.d=gmail.com header.s=20221208 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1685536767; bh=6YbfNFBpgVcaLVHgqhEIVT0sAibylz8iK6zXddNuOS4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=mMFdH5aWktry9J+vSX2+xpWM6/SgKq8YrmONk0kSaZLQlwnYXO3aadd4WkJhovWQNYN59DagKS 9b2KxfCB/bY1sxZss7/noH0hz6xmHKEF5NJDU1q+nppM6HUvGYJo1kN0mRO3W/4chemSbl8l+W LP+NLVpdsExbFqcLYUqrbudVvaJ1wIGiLhpF9hmLgT+mD7SowyK6sROf3Wd3FtsKFuzLGHZh5e o7lKspEROinYpJ+prfSLUFXbpQjD27Ldh/3FZ4aHPGJa35lv5OlSW2qrs2ROdcZkPRwgBumJDb m4Qn4C2PMTN+QUasXPuAPbIawcjai4fv7xlRQniHGkyFtA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=x9jvFmYXUQEfnbzuu0K4614fWFhwvVuu9VyhQIOIDXg=; b=cRm6e2fjc82/z1xEX906b96VDM cePNWMvY8GIx52lZuRJF+W2tCE8PDm+85bs1lznOdzd9ccKAZyr5EQP0vstE69bRw7+pGz/+aAnet 5tgplU66U7zHL53bLmhMx8OHyYsAxGtHyukIv0wyxPc+WjeYOwBoRiUxnvjc3jpqDMYfYbzCd56Q4 +Sy37uCSFCjyT8q+67F3L1gJ5hNSU7af5gO0OoSj2JDvUcSnojjxr2hUWumxBx7YX4IHf7tTLPjG6 5PiFR8LVABO6faxxsQx/yt33wKna6xbnRiMnEdrkrYclMnBtofIIdIqhW6pH49NxE7fvrdSpHTin8 hp2km9zQ==; Received: by zero.zsh.org with local id 1q4L6r-000Ew6-8I; Wed, 31 May 2023 12:39:25 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f175.google.com) smtp.remote-ip=209.85.208.175; dkim=pass header.d=gmail.com header.s=20221208 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f175.google.com ([209.85.208.175]:42444) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1q4L6J-000EdU-30; Wed, 31 May 2023 12:38:52 +0000 Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2af1c884b08so11513501fa.1 for ; Wed, 31 May 2023 05:38:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685536730; x=1688128730; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=x9jvFmYXUQEfnbzuu0K4614fWFhwvVuu9VyhQIOIDXg=; b=pBj7CmNWV7FgETFB0x5d1LQJcTC2dtR4+IybbclR0/XPW9+EZdWi+vTG6x/UDzXAcm QpwlDdzNwupG+0ZPworFfM+W6KQvwaKTVdojwm3ma3NUVxNc8TP+xK1TdHkKe3k0RJWN 192jhtOeEZH8XzQ+HWofwPwtWtxgjpVwTTPXcCbO7dOAm9O5XXwDNbZdhGNxXsHvrAJ7 ABmRO0yaYX0INRFjN5tjEyH6eXjjOUXHEgtUr98oOsIgRayzXEXjcWW9U6i6lzAXqXfL r5YHa7KFmfCUe9nOTresVKJYqh0Uq4tPq9kw9X4KkMwvlCfHD5kQwWKiIACeO36ruKKp HAeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685536730; x=1688128730; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x9jvFmYXUQEfnbzuu0K4614fWFhwvVuu9VyhQIOIDXg=; b=Pca16470KWc09tNTxX84UpBM09w9A0TtVAnpHNhWHMW/o6j563LYGh6OUdchmj0JJg /v4g3j7Tda/eU9CwBZRQGmfyaZRzU5f/bosxkH6JqTP//kDuqBdejjt8vAgKWGO0dS1J QpvOnSF2R3cDnPDzM0Yk/fKBmjuohrpNn9685mizeM17lKF0YW22Jk/3TUhJuOA0xigf MOuHy3PBnbjoI+d1jeZ/echyRquamgQDmFZ9hUw2000DF4JKo2sv8TuSG648VBbaAwVq hhV7Db1Q5RBWq0pAO86dKTZYeWiyMtQaQeBUdYUbHDn7soERKIHRXRlzE4N+WNR5TBPM 6r0g== X-Gm-Message-State: AC+VfDyinulAhtcLePMq8LrHNukp5XOVnQIuDTTgQerV/kuey4LNCpap 0z7LvH7/iaWVDNdYgsGGTO1ntsSWBGY/2lzDaBs= X-Google-Smtp-Source: ACHHUZ6UJOiIvcRa/E5Bj4CeVjhknfXcTtwYwX1kpCELME9wDc4PAiAlTxMlccj2YphbxQdZA8LyCgPkKtRvp9KjfCI= X-Received: by 2002:a2e:7a07:0:b0:2b0:8632:238d with SMTP id v7-20020a2e7a07000000b002b08632238dmr1935782ljc.15.1685536729650; Wed, 31 May 2023 05:38:49 -0700 (PDT) MIME-Version: 1.0 References: <1297534493.4668003.1685024167868@mail.virginmedia.com> <833370431.820192.1685445478652@mail.virginmedia.com> In-Reply-To: <833370431.820192.1685445478652@mail.virginmedia.com> From: Sebastian Gniazdowski Date: Wed, 31 May 2023 12:38:22 +0000 Message-ID: Subject: Re: stdbuf -o0 -i0 via a Zsh native interface? To: Peter Stephenson Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 51811 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: The problem with unbuffer is that it doesn't work=E2=80=A6 It's just a simp= le 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 wrote: > > > On 25/05/2023 19:35 Bart Schaefer wrote: > > On Thu, May 25, 2023 at 7:16=E2=80=AFAM Peter Stephenson > > wrote: > > > > > > > On 25/05/2023 12:21 Sebastian Gniazdowski = wrote: > > > > However, this is sub-optimal solution because I have to hideously > > > > prepend the stdbuf command before each user CMD, meaning that enter= ing > > > > 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 =3D zgetenv("ARGV0"))) { > --=20 Best regards, Sebastian Gniazdowski