forked from ungleich-public/cdist
introduce and use __cdist_echo
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
4165b4fe15
commit
723046fdd2
1 changed files with 21 additions and 6 deletions
|
@ -148,22 +148,37 @@ __cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX")
|
||||||
################################################################################
|
################################################################################
|
||||||
# Internal functions
|
# Internal functions
|
||||||
#
|
#
|
||||||
__cdist_debug_echo()
|
__cdist_echo()
|
||||||
{
|
{
|
||||||
|
__cdist_echo_type="$1"; shift
|
||||||
|
|
||||||
|
case "$__cdist_echo_type" in
|
||||||
|
debug)
|
||||||
if [ "$__cdist_debug" ]; then
|
if [ "$__cdist_debug" ]; then
|
||||||
echo "Debug: $@"
|
echo "Debug: $@"
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
info)
|
||||||
|
echo "$@"
|
||||||
|
;;
|
||||||
|
error)
|
||||||
|
echo "Error: $@" >&2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
__cdist_exec_fail_on_error()
|
__cdist_exec_fail_on_error()
|
||||||
{
|
{
|
||||||
sh -e "$@"
|
sh -e "$@"
|
||||||
[ "$?" -eq 0 ] || __cdist_exit_err "$1 exited non-zero."
|
if [ "$?" -ne 0 ]; then
|
||||||
|
__cdist_echo error "$1 exited non-zero."
|
||||||
|
__cdist_exit_err "$1 exited non-zero."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
__cdist_exit_err()
|
__cdist_exit_err()
|
||||||
{
|
{
|
||||||
echo "Error: $@" >&2
|
__cdist_echo error "$@"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue