mirror of
https://github.com/sstephenson/bats.git
synced 2024-12-29 07:59:45 +01:00
feat(run): Make possible to run to register stdout and stderr in separate variables
This commit is contained in:
parent
efd492cb1e
commit
5bbdb8216c
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user