Re: is there a way to save stdout and stderr to two bash variables?
From:
Peng Yu
Subject:
Re: is there a way to save stdout and stderr to two bash variables?
Date:
Mon, 11 May 2020 16:13:56 -0500
But this solution still involves using external files if I read the
code correctly? Thanks.
On 5/11/20, Koichi Murase <address@hidden> wrote:
> 2020-05-11 6:55 Peng Yu <address@hidden>:
>>
>> x=$(cmd)
>>
>> The above syntax can only save stdout to a bash variable. Is there a
>> way to save the stdout and stderr of the command to two different
>> bash variables? Thanks.
>
> You can use `ble/util/assign' in the following post:
>https://lists.gnu.org/archive/html/help-bash/2020-05/msg00057.html
>
> ble/util/assign stderr '
> ble/util/assign stdout "cmd" 2>&1'
>
> It works because `ble/util/assign' executes commands in the same
> process without fork. Actually, there is a use case here:
>
>https://github.com/akinomyoga/ble.sh/blob/54769337/lib/core-test.sh#L155-L156
>
> --
> Koichi
>
--
Regards,
Peng