|
| From: | Koichi Murase |
| Subject: | Re: is there a way to save stdout and stderr to two bash variables? |
| Date: | Tue, 12 May 2020 03:24:37 +0900 |
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
| [Prev in Thread] | Current Thread | [Next in Thread] |