1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-11-17 11:42:33 +01:00

feat(run): Make possible to run to register stdout and stderr in separate variables

This commit is contained in:
Frédéric Combes 2017-09-12 14:25:34 +02:00
parent efd492cb1e
commit 5bbdb8216c

View File

@ -55,10 +55,18 @@ run() {
set +e set +e
set +E set +E
set +T set +T
output="$("$@" 2>&1)"
status="$?" eval "$({ t_sdterr=$({ t_stdout=$("$@"); t_ret=$?; } 2>&1; declare -p t_stdout >&2; declare -pi t_ret >&2); declare -p t_sdterr; } 2>&1)"
status=$t_ret
output="${t_stdout}${t_sdterr}"
stdout=$t_stdout
stderr=$t_sdterr
oldIFS=$IFS oldIFS=$IFS
IFS=$'\n' lines=($output) IFS=$'\n' lines=($output)
IFS=$'\n' stdlines=($t_stdout)
IFS=$'\n' errlines=($t_sdterr)
[ -z "$e" ] || set -e [ -z "$e" ] || set -e
[ -z "$E" ] || set -E [ -z "$E" ] || set -E
[ -z "$T" ] || set -T [ -z "$T" ] || set -T