diff options
author | Mark Ferrell <major@homeonderanged.org> | 2014-01-15 11:38:57 -0800 |
---|---|---|
committer | Mark Ferrell <major@homeonderanged.org> | 2014-01-15 11:38:57 -0800 |
commit | e351728d111ef74730b4dd54e506b2a692c79bb5 (patch) | |
tree | 569edac220e9169c59bd9112e0cc47f462b97bc0 /build | |
parent | 6856f5c1b47b4f44b57fe33938d4bcceeb2a4936 (diff) |
Exit with the proper exit status
* We use 'tee' to view our logs AND log it at the same time. Unfortunately
'tee' eats the exit status of 'make'. Bash has a solution for this via the
PIPEFAIL variable, but that approach is not entirely portablt. The only
solution I have been able to come up with that is reasonably portable is to
use a named pipe and put tee into the background. Fixes #52
Diffstat (limited to 'build')
-rwxr-xr-x | build | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -79,7 +79,8 @@ mkenv() # deal with temporary junk when we exit cleanup() { - [ -f "${BUILDER_MAKEFILE}" ] && rm -f "${BUILDER_MAKEFILE}" + test -f "${BUILDER_MAKEFILE}" && rm -f "${BUILDER_MAKEFILE}" + test -p "${BUILDER_PIPE}" && rm -f "${BUILDER_PIPE}" } ## error <message> @@ -358,13 +359,12 @@ done set -- ${packages} unset packages -# The 'tee' command will discard the exit status from 'make', so we capture it -# via a wrapper function so we can exit properly. -build_make() -{ - BUILD_EXIT='0' - make -r -f "${BUILDER_MAKEFILE}" "${@}" - BUILD_EXIT="$?" -} -build_make "${@}" 2>&1 | tee "${BUILDER_TMPDIR}/builder.log" -exit ${BUILD_EXIT} +# The 'tee' command will discard the exit status from 'make', so we have to +# jump through a few hoops to capture the exit status in a portable fashion. +BUILDER_PIPE="`mktemp "${BUILDER_TMPDIR}/builder_pipe.XXXXXXXX"`" +test -f "${BUILDER_PIPE}" || die 'failed to generate log-pipe placeholder' +rm -f "${BUILDER_PIPE}" && mkfifo "${BUILDER_PIPE}" || die 'failed to create log-pipe' +tee "${BUILDER_TMPDIR}/builder.log" < "${BUILDER_PIPE}" & +BUILDER_LOGGER="$!" +make -r -f "${BUILDER_MAKEFILE}" "${@}" > "${BUILDER_PIPE}" 2>&1 +exit $? |