mirror of
https://git.busybox.net/buildroot.git
synced 2024-11-23 13:33:28 +08:00
dc364c6ae6
In utils/brmake line 6: local found ret start d h m mf ^---^ SC2034: found appears unused. Verify use (or export if used externally). In utils/brmake line 16: > >( while read line; do ^--^ SC2162: read without -r will mangle backslashes. For both, the suggestions from shellcheck can be applied. Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
43 lines
973 B
Bash
Executable File
43 lines
973 B
Bash
Executable File
#!/bin/bash
|
|
# (C) 2016, "Yann E. MORIN" <yann.morin.1998@free.fr>
|
|
# License: WTFPL, https://spdx.org/licenses/WTFPL.html
|
|
|
|
main() {
|
|
local ret start d h m mf
|
|
|
|
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 "${@}"; ) \
|
|
> >( while read -r line; do
|
|
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"; }
|
|
printf "%${sf}ds" ${d}
|
|
|
|
if [ ${ret} -ne 0 ]; then
|
|
printf " (error code: %s)" ${ret}
|
|
fi
|
|
printf "\n"
|
|
|
|
return ${ret}
|
|
}
|
|
|
|
main "${@}"
|