From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: TJ Luoma <luomat@gmail.com>
Cc: Aryn Starr <whereislelouch@icloud.com>,
Zsh MailingList <zsh-users@zsh.org>
Subject: Re: Capture stdout, stdin, and exit status in different variables without using temporary files
Date: Fri, 16 Aug 2019 15:16:28 +0200 [thread overview]
Message-ID: <CAN=4vMooZK0Ha3j-4n=Vpido6AXx2vnc0mwx6QFfZgv4hHPSWQ@mail.gmail.com> (raw)
In-Reply-To: <CADjGqHva=YphU8hy+N2psfDNAAW1ZqSd5+=hgms5UcDo9o5YPA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 748 bytes --]
On Fri, Aug 16, 2019 at 3:03 PM TJ Luoma <luomat@gmail.com> wrote:
> I have used this, which I am sure someone on the zsh probably gave me:
>
> (){ STDOUT=$( your-command-here 2> $1) STDERR=$(<$1);} =(:)
>
The OP is asking for a solution that doesn't use temporary files, so this
doesn't fit.
FWIW, this recipe is what I use when I need to capture stdout and stderr.
It works great. On modern Linux distros /tmp is usually on an in-memory
filesystem, so no disk IO happens when you are using temporary files. Even
when you have to hit disk, modern SSDs are very fast, with read/write
speeds over 3GB per second. Having sequential SSD reads/writes as a
bottleneck is a tough task even for C code and virtually impossible for zsh
scripts.
Roman.
next prev parent reply other threads:[~2019-08-16 13:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <D639E5A6-A28C-40EE-B0E6-27BED4C8CDDB__31117.9253900022$1565917892$gmane$org@icloud.com>
2019-08-16 7:22 ` Stephane Chazelas
2019-08-16 10:05 ` Stephane Chazelas
2019-08-16 10:45 ` Aryn Starr
2019-08-16 13:01 ` TJ Luoma
2019-08-16 13:16 ` Roman Perepelitsa [this message]
2019-08-16 17:08 ` TJ Luoma
2019-08-15 15:52 Aryn Starr
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='CAN=4vMooZK0Ha3j-4n=Vpido6AXx2vnc0mwx6QFfZgv4hHPSWQ@mail.gmail.com' \
--to=roman.perepelitsa@gmail.com \
--cc=luomat@gmail.com \
--cc=whereislelouch@icloud.com \
--cc=zsh-users@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).