zsh-users
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: robobenklein@gmail.com
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Capturing STDOUT without subshells or file I/O
Date: Tue, 18 Sep 2018 07:12:11 +0200	[thread overview]
Message-ID: <CAKc7PVAxFi0de0odscOMe5h3hP2qjWc2-AOr7kNb=yKxDBpNXw@mail.gmail.com> (raw)
In-Reply-To: <04a12c6a-c926-b088-f386-8a2bdb81dad2@gmail.com>

On Sun, 2 Sep 2018 at 22:59, Ben Klein <robobenklein@gmail.com> wrote:
>
> Hello Zshellers,
>
> I have an interesting predicament, I with to capture the STDOUT (builtin printf) of a ZSH function to a variable, in which the function should be running in the current shell context.

mksh can do this with:

${ foo;}

foo runs in current shell and the ${ ... } is substituted with its
output. One more cool thing mksh has - ${|foo;} which is replaced by
the value of REPLY after running foo in current shell. I think that
each time a serious, optimized coding occurs (like when creating an
advanced theme), those will be very handy.

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

  parent reply	other threads:[~2018-09-18  5:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-02 20:57 Ben Klein
2018-09-03  0:40 ` Joey Pabalinas
2018-09-03 14:02 ` Daniel Shahaf
2018-09-03 18:43   ` Joey Pabalinas
2018-09-17 20:13     ` Ben Klein
2018-09-17 20:46       ` Daniel Shahaf
2018-09-17 21:01         ` Mikael Magnusson
2018-09-17 21:20           ` Bart Schaefer
2018-09-17 21:19       ` dana
2018-09-17 21:33         ` Bart Schaefer
2018-09-18  5:12 ` Sebastian Gniazdowski [this message]
2018-09-21  6:58   ` Oliver Kiddle

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='CAKc7PVAxFi0de0odscOMe5h3hP2qjWc2-AOr7kNb=yKxDBpNXw@mail.gmail.com' \
    --to=sgniazdowski@gmail.com \
    --cc=robobenklein@gmail.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).