When running as part of a `&&` chain, Bash's `set -e` behaviour is
suppressed entirely, which means calls that produce non-zero error codes
will be ignored if they're called inside functions that are part of such
a chain.

To avoid silent failures from commands in a src_install function being
ignored, don't chain the function calls with &&, and instead just let
Bash's `set -e` behaviour handle failures.
---
 bin/cygport.in | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/bin/cygport.in b/bin/cygport.in
index 3f89ac67..3bf4a4fa 100755
--- a/bin/cygport.in
+++ b/bin/cygport.in
@@ -679,7 +679,11 @@ do
                inst*)
                        __stage Installing;
                        __log_init ${installlog};
-                       (__prepinstalldirs && src_install && __src_postinst) 
2>&1 | tee -a ${installlog};
+                       {
+                               __prepinstalldirs
+                               src_install
+                               __src_postinst
+                       } 2>&1 | tee -a ${installog};
                        _status=${PIPESTATUS[0]};
                        ;;
                postinst*)
@@ -764,12 +768,20 @@ do
                        __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_tag} && __pkg_dist ${_pkg_tag}) 2>&1 | tee -a ${pkglog} && \
-                       test ${PIPESTATUS[0]} -eq 0
-                       _status=$?;
+                       __stage Installing
+                       {
+                               __prepinstalldirs
+                               src_install
+                               __src_postinst
+                       } 2>&1 | tee -a ${installlog};
+                       if test ${PIPESTATUS[0]} -eq 0; then
+                               __log_init ${pkglog} && \
+                               __stage Packaging && (__pkg_binpkg && 
__pkg_pkgcheck && __pkg_srcpkg ${_pkg_tag} && __pkg_dist ${_pkg_tag}) 2>&1 | 
tee -a ${pkglog} && \
+                               test ${PIPESTATUS[0]} -eq 0
+                               _status=$?;
+                       else
+                               _status=1;
+                       fi
                        ;;
                help)
                        __show_help;
-- 
2.40.1

Reply via email to