Last active
June 23, 2018 10:27
-
-
Save timbertson/b619802d795c270f80886cee8efd4191 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
output="/tmp/$$.log" | |
idx=0 | |
touch "$output" | |
NTH_LINE="${NTH_LINE:-100}" | |
ERROR_LINES="${ERROR_LINES:-200}" | |
function cleanup () { | |
rm -f "$output" | |
} | |
trap cleanup EXIT | |
echo 'travis_fold:start:output-stream' | |
echo "+ $@ # showing every ${NTH_LINE}th line" | |
"$@" 2>&1 | tee "$output" | while read line; do | |
idx=$((idx+1)) | |
if [ $(($idx % $NTH_LINE)) -eq 0 ]; then | |
echo "... # $line" | |
fi | |
done | |
status="${PIPESTATUS[0]}" | |
echo 'travis_fold:end:output-stream' | |
echo "" | |
if [ "$status" -eq 0 ]; then | |
echo "# Success" | |
else | |
echo "# Exited with status $status. Showing the last $ERROR_LINES lines of output:" | |
tail -n "$ERROR_LINES" "$output" | |
exit "$status" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment