2017-07-01 22:31:07 +08:00
|
|
|
#!/bin/bash
|
|
|
|
# (C) 2016, "Yann E. MORIN" <yann.morin.1998@free.fr>
|
|
|
|
# License: WTFPL, https://spdx.org/licenses/WTFPL.html
|
|
|
|
|
|
|
|
main() {
|
2023-02-08 20:40:36 +08:00
|
|
|
local ret start d h m mf
|
2017-07-01 22:31:07 +08:00
|
|
|
|
|
|
|
if ! which unbuffer >/dev/null 2>&1; then
|
|
|
|
printf "you need to install 'unbuffer' (from package expect or expect-dev)\n" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
start=${SECONDS}
|
|
|
|
|
|
|
|
( exec 2>&1; unbuffer make "${@}"; ) \
|
2023-02-08 20:40:36 +08:00
|
|
|
> >( while read -r line; do
|
2017-07-01 22:31:07 +08:00
|
|
|
printf "%(%Y-%m-%dT%H:%M:%S)T %s\n" -1 "${line}"
|
|
|
|
done \
|
|
|
|
|tee -a br.log \
|
|
|
|
|grep --colour=never -E '>>>'
|
|
|
|
)
|
|
|
|
ret=${?}
|
|
|
|
|
|
|
|
d=$((SECONDS-start))
|
|
|
|
printf "Done in "
|
|
|
|
h=$((d/3600))
|
|
|
|
d=$((d%3600))
|
|
|
|
[ ${h} -eq 0 ] || { printf "%dh " ${h}; mf="02"; }
|
|
|
|
m=$((d/60))
|
|
|
|
d=$((d%60))
|
|
|
|
[ ${m} -eq 0 ] || { printf "%${mf}dmin " ${m}; sf="02"; }
|
2017-07-05 05:53:15 +08:00
|
|
|
printf "%${sf}ds" ${d}
|
|
|
|
|
|
|
|
if [ ${ret} -ne 0 ]; then
|
|
|
|
printf " (error code: %s)" ${ret}
|
|
|
|
fi
|
|
|
|
printf "\n"
|
2017-07-01 22:31:07 +08:00
|
|
|
|
|
|
|
return ${ret}
|
|
|
|
}
|
|
|
|
|
|
|
|
main "${@}"
|