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

Re: capture stderr in command substitution



On 2021-01-24 11:47 a.m., Axel Beckert wrote:

   $ var=$(command 2>&1)

Thanks, superficial testing shows it working fine.  I finally sorta understand it too, you can read it as 'output #2 goes back to output #1.

var=$(cmd>&2)

That seems not to work but I'm in no mood to look into it so long as Axel's performs.

{ var=$(cmd 2>&1 >&3 3>&-); } 3>&1

... is not something that the eye's of a mortal should ever look upon ;-)

BTW (not worth starting a thread on this) how do you keep a command out of history?  I usta know this but can't remember and I've written it down somewhere but can't find it :(
I take a year off from coding anything and forget 101% of what I had learned.





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