[PATCH] cygport: propagate exit status

Jon Turney jon.turney@dronecode.org.uk
Wed Apr 6 13:05:00 GMT 2016


The commands compile, check, inst, package and all currently return the exit
status of the last command in the pipeline, tee, which they pass their
output through.

I guess we don't want to just turn on pipefail, since pkg_pkg very carefully
turns it on and off in a particular place, so use $PIPESTATUS to propagate
the much more interesting exit status of the command who's output is tee'd.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
---
 bin/cygport.in | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/bin/cygport.in b/bin/cygport.in
index b032b8b..4abca88 100644
--- a/bin/cygport.in
+++ b/bin/cygport.in
@@ -561,19 +561,19 @@ do
 			__log_init ${compilelog};
 			__check_depends && \
 			src_compile 2>&1 | tee -a ${compilelog};
-			_status=$?;
+			_status=${PIPESTATUS[0]};
 			;;
 		check|test)
 			__stage Testing;
 			__log_init ${checklog};
 			src_test 2>&1 | tee -a ${checklog};
-			_status=$?;
+			_status=${PIPESTATUS[0]};
 			;;
 		inst*)
 			__stage Installing;
 			__log_init ${installlog};
 			(__prepinstalldirs && src_install && __src_postinst) 2>&1 | tee -a ${installlog};
-			_status=$?;
+			_status=${PIPESTATUS[0]};
 			;;
 		postinst*)
 			__src_postinst;
@@ -603,7 +603,7 @@ do
 			__stage Packaging;
 			__log_init ${pkglog};
 			(__pkg_binpkg && __pkg_pkgcheck && __pkg_srcpkg && __pkg_dist) 2>&1 | tee -a ${pkglog};
-			_status=$?;
+			_status=${PIPESTATUS[0]};
 			;;
 		diff|mkdiff|mkpatch)
 			__pkg_diff;
@@ -613,7 +613,7 @@ do
 			__stage Uploading;
 			__log_init ${uploadlog};
 			(__pkg_upload) 2>&1 | tee -a ${uploadlog};
-			_status=$?;
+			_status=${PIPESTATUS[0]};
 			;;
 		announce)
 			__stage "Preparing announcement";
@@ -629,10 +629,13 @@ do
 			__log_init ${compilelog} && \
 			__check_depends && \
 			__stage Compiling && src_compile 2>&1 | tee -a ${compilelog} && \
+			test ${PIPESTATUS[0]} -eq 0 && \
 			__log_init ${installlog} && \
 			__stage Installing && (__prepinstalldirs && src_install && __src_postinst) 2>&1 | tee -a ${installlog} && \
+			test ${PIPESTATUS[0]} -eq 0 && \
 			__log_init ${pkglog} && \
-			__stage Packaging && (__pkg_binpkg && __pkg_pkgcheck && __pkg_srcpkg && __pkg_dist) 2>&1 | tee -a ${pkglog}
+			__stage Packaging && (__pkg_binpkg && __pkg_pkgcheck && __pkg_srcpkg && __pkg_dist) 2>&1 | tee -a ${pkglog} && \
+			test ${PIPESTATUS[0]} -eq 0
 			_status=$?;
 			;;
 		help)
-- 
2.7.4



More information about the Cygwin-apps mailing list