Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Capturing STDOUT without subshells or file I/O



On Sun, 2 Sep 2018 at 22:59, Ben Klein <robobenklein@xxxxxxxxx> 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



Messages sorted by: Reverse Date, Date, Thread, Author