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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8307 invoked from network); 13 May 2022 19:13:30 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 May 2022 19:13:30 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1652469210; b=dpkepR41QxbhW5jF3678VFr3CXvAmaGgAYWSWTq+ii+ThnHgZZJONd817fRl077y8DRGRriQNV L4RBDQ6OnK9tPANCDa/3tbZWdZVf07OTpsFu43TZzEm5iIrN8H8DPEtRPsMdxgqy1gAJC+Z/er ++20U7XYUehXcuQE/e9QRj6Xr7QHiBNKmA9tytQ6DKPlFiFPNRYdx7D4QHFH6WDLb8JtCYDZHu 2YULxX28cT41MNnvFbiqlBIjqriTjxNsuLKL3fPXSjdw+L9JUdFe71vOr4jeO4FH1u4rJQpTTw QrE9jNforzZQvxtZKDoHSGFY1lvb4UBXbzoSCiaZP0GXxg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f44.google.com) smtp.remote-ip=209.85.218.44; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1652469210; bh=d3z/i4Fkpybf9cSKnRVCBIL4JEsDx7m+X22ugMxbn+c=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=n8oADl3EcSDuA4g/vRvkT7pnfoUuUg1zRnNILPU93HXOK8pW77Ss3KWNd3nHcPbuWeVJRGAyeC 2ahRCj+s7jwlqLuNBLA67CBY3IH0UXbNQtu50rIj39D3uVUtvcHG+KFYIGE06jw+e2XU/MvwsG 8HdMer1jeOPkuFDO1OLKTXC3R3wPxIHtTq+hQPMJBhBeQUodn8fm0fbrWmMtB1mm5eugMEoPY8 IDAHnph7D6yQxVz4wqmMVivnD1Nkm9vNCCAd0pfi12vDASFTpSgoyBpPS+UvMT9c0Lk+wMEMeN ObGYXAPXUiZnNRIc1ZoApUZO6TuEkpzAVCh628NiaMMWeg==; 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-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=2SRJp/OsbSvb2LeiNS8rykQ5OoB20yIItGlWxPKRtLE=; b=Y0vcSDQLsSzjeLOtQ36RB7Xt34 k3vWDOT4IXvJi2OtSwTGGzoWFxaOvLD3QemeIRG/euhcYF25DefeaKL2eCmpVNEX3swP/Xd0/pukU TMPtmKMCvBQsUi1yDqc6h36b0HXlAymTqPKrTbdMuDTRbOqLlZOCShtXFBwrwcuciFp3uAugKPFUv 3lLcHvn5Ek2+kH6YG2P7mooUxicBIkmTgIa5VLcSLruW8B50mCLAH9CVz4ETRFuOABSGCALeLI2mz 7dVqwKoLCwwDnY2oTrS45QbyBCsmOlr44Hlt6aXf8bkUZe6pfsKDCH5eeFdHlEswJUSfMl7RCq9UG xVruoB+g==; Received: from authenticated user by zero.zsh.org with local id 1npajC-00091G-GW; Fri, 13 May 2022 19:13:30 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f44.google.com) smtp.remote-ip=209.85.218.44; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f44.google.com ([209.85.218.44]:44609) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1npaiN-0008Je-NW; Fri, 13 May 2022 19:12:40 +0000 Received: by mail-ej1-f44.google.com with SMTP id i19so17959965eja.11 for ; Fri, 13 May 2022 12:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2SRJp/OsbSvb2LeiNS8rykQ5OoB20yIItGlWxPKRtLE=; b=nk9pI/5WdV/v47Xm7D6lJg5ZLwTrvoYGMJFogXUPiNOlTY4AQOSrYGXj+1f7O77hsR oYsEEpwU8O7Yj89eD3MeMMlE91r0JdkGIvnP22fwWnxFNQGLLQtFX/qNA/aDCpQ8dl7e vnQGSqE8vMLdDhbvSglEg7FXelkgnnKqLwBinCf+0DJezIGtx8L+3L5ULzble/XbZMIh PIzI+q+YP5n/wnYYgXend37j0NcFVTFV0jWst+rV7TDimzz0PJ3pbz7HXkzivj1hSzII Lu9tdqIY+vqgAVDEUhLQw6gE6OAjA7sQB15hlQcnpGqF3FLX9f5Jq4pVKPmLST3lCiBs 4srQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2SRJp/OsbSvb2LeiNS8rykQ5OoB20yIItGlWxPKRtLE=; b=DrRmCupwahEft1JeqSpoDD2V84yw2pV+xiDKFe+r/bbZcN0XVUb8LTA29BsHU1k5Rd mZEh4uSK2ZtI2oLE/bZZmJILt55eMJubaMU9KXivkPHjLAxHUcnzme7uX8bBrODEikAk 0mEXHW9EhQAFrEp7rJLHaV1KO5xiIgaRS/v1jEqnuk/NBVgzAMipNK+OfdNlxOT9HHiY w+/d0NMJfi7OsJ74kx7IhWq7aEWVtLk5Q3ekcCnLJ76/bF6Xp/cAZ2exYVJQ85gxr7jC aieDhdGhoSxTbe3O+6vWwPOuEKsjpVqQH55BeKKlMR0NokCfo9BQ51ZhOMZ4mJQbk3lV jZgQ== X-Gm-Message-State: AOAM531vEQhF+NnLl73NV6sUAv2p5yr4U/WpJk3gYNPwln0Y38hra4J6 UBg3xbGvW+W8tuCvhU9D04nTGEKI+/lsCGx4Jm5ieFb5jvQ= X-Google-Smtp-Source: ABdhPJxqjbKne4bfI40YMewo13qReeFFCt+AhfaUsrc58NSAXjpX1oFR6idTr6oQVy7PwwYO9SDv42+J+BcALOqrWLI= X-Received: by 2002:a17:907:728f:b0:6f4:5d2d:38c8 with SMTP id dt15-20020a170907728f00b006f45d2d38c8mr5537033ejc.345.1652469159153; Fri, 13 May 2022 12:12:39 -0700 (PDT) MIME-Version: 1.0 References: <2282060.4c44sqeuZD@march> In-Reply-To: <2282060.4c44sqeuZD@march> From: Bart Schaefer Date: Fri, 13 May 2022 12:12:27 -0700 Message-ID: Subject: Re: gnu script and zsh: only log command output To: "chiasa.men" Cc: "zsh-users@zsh.org" Content-Type: text/plain; charset="UTF-8" X-Seq: 27759 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Thu, May 12, 2022 at 11:46 AM chiasa.men wrote: > > When I use "script --log-output o --log-input i" I am facing two problems: > > 1: The output log contains the actual input: e.g. ".]0;test@test: echo 5.5" > (see below) > 2: The prompts This is going to happen because "script" has taken over the terminal device and ZLE must necessarily write to that terminal to display the prompts and to echo back your keystrokes as it maintains the "editor" state. Everything that comes and goes to the terminal is potentially captured by "script" and there's no way for you to see/interact with it that bypasses that. You can try switching off ZLE if you can stand to work that way, but I think you'd still get the prompts captured. > I really just want the programs output logged - no prompts, no shell-related > output. > > Is that possible? It's a bit difficult in zsh up to 5.8.1 ... once 5.9 is released, you should be able to do something like this: autoload add-zsh-hook exec {stdout}>&1 {stderr}>&2 preexec_outputs() { exec 2>>|stderr.log 2>&$stderr exec 1>>|stdout.log 1>&$stdout } precmd_outputs() { exec 1>&$stdout 2>&$stderr } add-zsh-hook preexec preexec_outputs add-zsh-hook precmd precmd_outputs However, this won't capture output of interactive programs like "vim" which will either fail or will re-open the terminal device directly (printing an error message first, in the case of vim). > So would there be a way to reliably filter the zsh-related output e.g. within > the _my_read_function function? Using preexec and precmd you could write markers to the output that would indicate when ZLE becomes active (precmd) and when it finishes (preexec). Your python script could then discard anything between those two markers. You'd have to be very sure that those markers would never appear in output you actually want captured.