You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

31 lines
627 B

#!/bin/bash
{
IFS=$'\n' read -r -d '' CAPTURED_STDERR
IFS=$'\n' read -r -d '' CAPTURED_STDOUT
} < <((printf '\0%s\0' "$(./useless.sh)" 1>&2) 2>&1)
echo 'Here is the captured stdout:'
echo "${CAPTURED_STDOUT}"
echo
echo 'And here is the captured stderr:'
echo "${CAPTURED_STDERR}"
echo
# function launch {
# echo START
# bash -c "set -TEue -o pipefail; . ./useless.sh"
# echo END
# }
#
# set -TEue -o pipefail
# stderr=$(launch 3>&1 1>&2 2>&3 | tee /dev/stderr)
# >&2 echo "ERR: $stderr"
# # (
# echo -n "ERR: "
# cat stderr
# ) >&2
# >&2 echo 'here is the captured stderr:'
# >&2 echo "$(<stderr)"
# >&2 echo