Define closeNest before exitHandler

This prevents "closeNest: command not found" messages if setup fails
early.
This commit is contained in:
Eelco Dolstra 2015-06-15 11:24:11 +02:00
parent 4982143324
commit 41e1900ea1

View File

@ -72,6 +72,35 @@ _eval() {
}
######################################################################
# Logging.
nestingLevel=0
startNest() {
nestingLevel=$(($nestingLevel + 1))
echo -en "\033[$1p"
}
stopNest() {
nestingLevel=$(($nestingLevel - 1))
echo -en "\033[q"
}
header() {
startNest "$2"
echo "$1"
}
# Make sure that even when we exit abnormally, the original nesting
# level is properly restored.
closeNest() {
while [ $nestingLevel -gt 0 ]; do
stopNest
done
}
######################################################################
# Error handling.
@ -409,32 +438,6 @@ substituteAllInPlace() {
# What follows is the generic builder.
nestingLevel=0
startNest() {
nestingLevel=$(($nestingLevel + 1))
echo -en "\033[$1p"
}
stopNest() {
nestingLevel=$(($nestingLevel - 1))
echo -en "\033[q"
}
header() {
startNest "$2"
echo "$1"
}
# Make sure that even when we exit abnormally, the original nesting
# level is properly restored.
closeNest() {
while [ $nestingLevel -gt 0 ]; do
stopNest
done
}
# This function is useful for debugging broken Nix builds. It dumps
# all environment variables to a file `env-vars' in the build
# directory. If the build fails and the `-K' option is used, you can