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=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 958 invoked from network); 26 May 2023 09:30:58 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 26 May 2023 09:30:58 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1685093458; b=nQyMmPYnpAVN7uXm38ajQg5cbA2lnA+jldWfne//bKs5JQ+2czzptUQ26eXzmjGa0HffPwXrfG gHgLb8vEb4n7iIovN+gnVyZX7igXNOk8sLm/V5ZVu9zq+ykBmiNG4v73QGaCh+EhrG9xP/bieV khmdt3R+VNbrB4KM6wCkHxU3Q+jU8YWclwQ9iI+tiwRl+gQjYohtVeX1iJE8xfKCvY1xZSuMZY 6S5SK8zZI9HViJXqy5zR3tGrCzc2RCUQgPY3fWCHt9QQA0HZe+wuOxSzHt6u14xtCRRBE+2JjG 1f3SKdL7FOSgMA6NpqxoZxuXTjqzmT9XwGHD9G6o9zinvQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lf1-f48.google.com) smtp.remote-ip=209.85.167.48; 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=1685093458; bh=Fgr14jRWUSh9Ahkw3ynlEKs/VwJcxlQQxY31spdrCoU=; 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=miV+ARLQnLPcW8cqGXzc9oOS8cYISx2DSD8vhza4qI6L3BtVta5fAbaSGnBs/VJpXLw36XEXZZ W+0v/xpmUQvRnNP5b0PvGpaiK+VrTtQZHl7u73Oy0b27GpGYlWB9/KRf24lc3ZUJu0QVHrAhTS j+P0ob6nZqTIg7C0g6PHSHzc+LwHlzKNN+F3QBZ6CDGtS1AACjt6ym7H1LEdzS8ctx7YNpwfQC vpb5tFvp9ts1xo/RpklmVRLf34d6Mqy5hDYH738JofwO5yZAxBMcjRrNozzmMfnSYjCThnDL1T PLrhZHoXTJGuEFqSupTNk/HJak8EAUs212hyWlPx7E3LvQ==; 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=Fgr14jRWUSh9Ahkw3ynlEKs/VwJcxlQQxY31spdrCoU=; b=Jg9QFWRUZk1r7BMbFJiPak1dZr DTdCaesmY7a6VKOx7QQyKCMvbXfPGtxSxNpMM1GhrGeV8SlvWaC8TRMTtUhYCN01upT5NgoOptSwo NbPA7ySWg+nIydjO41gvY2/K/0vnwT0tzSAB56d8U6io9aOelXWyw5oFFr5yhJAyCtUNJdgxeXGSO 892HUnegtCnlMWVnbiq/E5u/S0sxTkH6R8CtyJbCv/4XcxpUEg3u22Zcu2Kxwrx4pxNhRHenMI9Dw F9R3ruetXTN8N4oaZUm5phAJzuQyTuCNcuEBF305EMG9MFI8KLmJ/1JDtkLdtGiPYC52OAcnKyCK5 gwO51LAA==; Received: by zero.zsh.org with local id 1q2Tmj-0008tJ-OX; Fri, 26 May 2023 09:30:57 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f48.google.com) smtp.remote-ip=209.85.167.48; dkim=pass header.d=gmail.com header.s=20221208 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lf1-f48.google.com ([209.85.167.48]:45496) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1q2TmR-0008Xk-8f; Fri, 26 May 2023 09:30:40 +0000 Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-4f3b39cea1eso513074e87.3 for ; Fri, 26 May 2023 02:30:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685093438; x=1687685438; 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=Fgr14jRWUSh9Ahkw3ynlEKs/VwJcxlQQxY31spdrCoU=; b=o0hz75WugvTNFHk5SdI70DeCgV2VoBdPJTTxX/tRGP1YrMrVdIQzmYwbbvSqsHlF/Z 9HMCjpoaXSQ+TUxKXtMD4gzY8ypSoaef7zfSZqhegW7gLO/7bRDazglDW4eIL498ss/E 1KCabeLM0rbT6rRUmLi8ZNdmIiPO95+RZTqtgb/kk71gNX9AmuYqTw+RRe1G/2wnjBUP bKb/l1TysMPAqbtnglW37dlIqtNG7qWAIPjPY9yOBNU06CN4Nvm7GgtE43na3/fbdZEs QDyPyr8CNXlmKLMiFuY/uU55XoSoPxq3lGJPUeWjsSzX7slibpW/rvrdLBzXXKKxWRQu rPig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685093438; x=1687685438; 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=Fgr14jRWUSh9Ahkw3ynlEKs/VwJcxlQQxY31spdrCoU=; b=YS+XWKQ0Vg14c5td7T85fpoe6JLgsmnBvCGsaTkejunbCzwI3QGT0u+cyGsWMcuku0 hXkDgZ+giFxlJm0jWqVNEH8yFd8vA5XT4O3crhuZPJSc1jNrqU2w32tC+NXoiD4IpYMX hj/cMSLLskkLx6IYBkIX/SL2877nwtIjv1yWk3LvpOq9IxJczJymnn75HUbj29AljFv8 m1tDqD5+sAMGUW9g5bGSHE22c7KD8LGcQWbUY9WSy446jWuVjECfDwczqEzmw9fU7iA1 kMZJnP4ZSAvcpbAi3epNU9orlRlbVEee8+Bsz6mYptwC4nLf/e/jcXFgGph0G6Btk51+ RMqw== X-Gm-Message-State: AC+VfDytqlRmujGRxTf4MzIt8SiHXrYGsFiWENm810wwYhGlk+JQmLti jb6gfBVYfSu5vGSmPCJcWcZs+9v8lKa7JB8L2b8= X-Google-Smtp-Source: ACHHUZ7BhJEHEUSxChKwE5x0GGkzsGif0sAciEYuINmCm9EZvcPfny8lygL6XRXpM1Jy35aI2oO2LB2XW8g92weCveQ= X-Received: by 2002:a2e:90d6:0:b0:2ad:f8d:dea with SMTP id o22-20020a2e90d6000000b002ad0f8d0deamr438378ljg.11.1685093438312; Fri, 26 May 2023 02:30:38 -0700 (PDT) MIME-Version: 1.0 References: <1297534493.4668003.1685024167868@mail.virginmedia.com> In-Reply-To: From: Roman Perepelitsa Date: Fri, 26 May 2023 11:30:27 +0200 Message-ID: Subject: Re: stdbuf -o0 -i0 via a Zsh native interface? To: Sebastian Gniazdowski Cc: Bart Schaefer , Peter Stephenson , Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 51797 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: On Fri, May 26, 2023 at 11:24=E2=80=AFAM Sebastian Gniazdowski wrote: > > I've took a look, and it seems to be easy: > 1. Export LD_PRELOAD=3D/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=E2=80=A6 This won't work reliably. E.g., it may not work on binaries that are linked against a different libc. A more reliable solution for your problem is something like `unbuffer` from `expect`. This tool creates a TTY and takes advantage of the convention that stdout to TTY is not buffered. Better yet, you can do this with zpty without external tools. Roman.