corrected KEEPGOING support, corrected noerror behaviour
This commit is contained in:
@@ -20,6 +20,8 @@ function die()
|
|||||||
|
|
||||||
if [[ "$KEEPGOING" != "true" ]] || [[ "$2" == "--force" ]]; then
|
if [[ "$KEEPGOING" != "true" ]] || [[ "$2" == "--force" ]]; then
|
||||||
prnt E "Sortie prématuré avec erreur (code #$errorcode)."
|
prnt E "Sortie prématuré avec erreur (code #$errorcode)."
|
||||||
|
# We remove KEEPGOING in case of --force so error() behave correctly
|
||||||
|
export KEEPGOING=false
|
||||||
exit $errorcode
|
exit $errorcode
|
||||||
else
|
else
|
||||||
prnt W "On continue malgrés l'erreur #$errorcode."
|
prnt W "On continue malgrés l'erreur #$errorcode."
|
||||||
@@ -61,7 +63,17 @@ function error()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# Trigger error function on error
|
# Trigger error function on error
|
||||||
trap "error ${LINENO}; backtrace; exit 255" ERR
|
trap "error ${LINENO}; backtrace; err_exit" ERR
|
||||||
|
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Exit program in case of error unless keepgoing is set to true
|
||||||
|
function err_exit
|
||||||
|
{
|
||||||
|
if [[ $KEEPGOING != true ]]; then
|
||||||
|
exit 255
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@@ -100,12 +112,12 @@ noerror()
|
|||||||
$@
|
$@
|
||||||
fi
|
fi
|
||||||
local code=$?
|
local code=$?
|
||||||
|
echo $code
|
||||||
|
|
||||||
trap "error ${LINENO}" ERR
|
trap "error ${LINENO}" ERR
|
||||||
set -o errexit
|
set -o errexit
|
||||||
|
|
||||||
echo $code
|
|
||||||
}
|
}
|
||||||
|
export -f noerror
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@@ -120,5 +132,6 @@ check_root()
|
|||||||
die 4 --force
|
die 4 --force
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
export -f check_root
|
||||||
|
|
||||||
# EOF
|
# EOF
|
||||||
|
|||||||
Reference in New Issue
Block a user