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

Re: Capturing STDOUT without subshells or file I/O



Ben Klein wrote on Sun, Sep 02, 2018 at 16:57:49 -0400:
> 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.

Just pass -v to the builtin printf, e.g.,

% printf -v foo 'a%03d' 42
% typeset -p foo
a042
% 



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