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

Re: capturing stderr to variable.



On 11/14/2015 09:20 AM, Ray Andrews wrote:


    { highlight ... >/dev/tty } 2>&1 | read highlight_err
    # now $highlight_err has the first line of stderr
    # (this does not work in most shells other than zsh)




And it's even simpler in case the output is to be captured and not echoed to stdout at all:

    body_list=( ${(@f)"$( highlight $filename )"} ) 2>&1 | read _err

If I do:

body_list=( ${(@f)"$( highlight $filename > /dev/tty )"} ) 2>&1 | read _err

... I get the output to screen, so that answers my previous question. The syntactic logic might be harder than Finnish, but it *is* there.



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