From 463d6db90b673a1de9765372d6b2413ea6f68052 Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Thu, 17 Aug 2017 10:16:25 +0200 Subject: [PATCH] home-manager: exit with an error on build failure Because 'set -e' has no effect on commands that run in an if condition, the script was always exiting with no error when 'doBuild' failed. As a bonus, $wrkdir is now always removed after building. (cherry picked from commit a9d9fb5d75b57fd9932aeab957c6b938fb6e41a2) --- home-manager/home-manager | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index d6d17053e..f599d9008 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -91,11 +91,13 @@ function doSwitch() { local wrkdir wrkdir="$(mktemp -d)" - if doBuild "$wrkdir/generation" ; then - "$wrkdir/generation/activate" - fi + local exitCode=0 + doBuild "$wrkdir/generation" && "$wrkdir/generation/activate" || exitCode=1 + # Because the previous command never fails, the script keeps running and + # $wrkdir is always removed. rm -r "$wrkdir" + return $exitCode } function doListGens() {