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.
This commit is contained in:
parent
ffbc7e723d
commit
02f0d92df7
|
@ -91,11 +91,13 @@ function doSwitch() {
|
||||||
local wrkdir
|
local wrkdir
|
||||||
wrkdir="$(mktemp -d)"
|
wrkdir="$(mktemp -d)"
|
||||||
|
|
||||||
if doBuild "$wrkdir/generation" ; then
|
local exitCode=0
|
||||||
"$wrkdir/generation/activate"
|
doBuild "$wrkdir/generation" && "$wrkdir/generation/activate" || exitCode=1
|
||||||
fi
|
|
||||||
|
|
||||||
|
# Because the previous command never fails, the script keeps running and
|
||||||
|
# $wrkdir is always removed.
|
||||||
rm -r "$wrkdir"
|
rm -r "$wrkdir"
|
||||||
|
return $exitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
function doListGens() {
|
function doListGens() {
|
||||||
|
|
Loading…
Reference in a new issue