use python rather than unbuffer

because unbuffer eats exit code when process is killed
This commit is contained in:
Patrick Schleizer 2017-02-27 23:16:32 +00:00
parent cc351165dc
commit 2130b4c654
No known key found for this signature in database
GPG key ID: CB8D50BB77BB3C48
2 changed files with 9 additions and 3 deletions

View file

@ -20,12 +20,18 @@ logfile="$temp_dir/log"
trap "cleanup" EXIT
apt_get_exit_code="0"
unbuffer apt-get "$@" 1> >(tee -a "$logfile") 2> >(tee -a "$logfile" >&2) || { apt_get_exit_code="$?"; true; };
python -c 'import pty, sys; pty.spawn(sys.argv[1:])' \
| apt-get "$@" 2>&1 \
| tee -a "$logfile" \
|| { apt_get_exit_code="$?"; true; };
if [ ! "$apt_get_exit_code" = "0" ]; then
exit "$apt_get_exit_code"
fi
log="$(cat "$logfile")"
while read -r -d $'\n' line; do
line_lower_case="${line,,}"
first_two="${line_lower_case:0:2}"