bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A feature request regarding redirection to variables


From: Oğuz
Subject: Re: A feature request regarding redirection to variables
Date: Mon, 18 Dec 2023 12:33:37 +0300

On Mon, Dec 18, 2023 at 7:39 AM Luke Tidd <lukeisgreat@gmail.com> wrote:
>
> A very common thing I need to do when writing bash is to collect both
> the stdout and stderr of a command. This can be done relatively
> reasonably with files but it would be very attractive to be able to
> redirect these directly to a variable some how.

The new no-fork command substitution feature already allows this:

    $ f(){ echo foo; echo bar >&2;}
    $ a=${ { b=${ f;};} 2>&1;}
    $ declare -p a b
    declare -- a="bar"
    declare -- b="foo"

You just need to wait for the next release



reply via email to

[Prev in Thread] Current Thread [Next in Thread]