Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Capture stdout, stdin, and exit status in different variables without using temporary files
- X-seq: zsh-users 24152
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: TJ Luoma <luomat@xxxxxxxxx>
- Subject: Re: Capture stdout, stdin, and exit status in different variables without using temporary files
- Date: Fri, 16 Aug 2019 15:16:28 +0200
- Cc: Aryn Starr <whereislelouch@xxxxxxxxxx>, Zsh MailingList <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jGxQOl4XFPAKCd4YzOws/do5idXJSpYydoLbQ7Yw/HA=; b=bv6hygdFc7jayoyyAIkj0XlxZwtPwjaSasMvuKuGVPj7KXHki87hyl5zM72e6smoYw CKNXLIf+Msl4xZlxUtQ7oQVkDbJguAJlefk1wgNOETBsNcDrDS2R8dW/1HktqTg0sHgq cFUUsQLb6cyOqrY4icS7l2RQt5liy57l9+VHfR2q3gs95SiTdF6RH0lNFwqazCBGGLpH 6cL7eszDSlX6W2hOhu6QoK6KdLMjoxYsCSpQIRDpklvdz8lb9BvZYZF0+D3jOnl27RRm DmeZJBQyxJJLtgphPlW3oJ4QPe22ZIREMHJS1v7X07vrtJPlBlLBMq+YIlp+NgWausQt AJQA==
- In-reply-to: <CADjGqHva=YphU8hy+N2psfDNAAW1ZqSd5+=hgms5UcDo9o5YPA@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <D639E5A6-A28C-40EE-B0E6-27BED4C8CDDB__31117.9253900022$1565917892$gmane$org@icloud.com> <20190816100501.nsvfbdwwnoaihlhe@chaz.gmail.com> <70382019-1857-4452-85FC-F038D8BBE206@icloud.com> <CADjGqHva=YphU8hy+N2psfDNAAW1ZqSd5+=hgms5UcDo9o5YPA@mail.gmail.com>
On Fri, Aug 16, 2019 at 3:03 PM TJ Luoma <luomat@xxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author