From 723046fdd2756bd7a3ed4905b71b3bca40f654d9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 6 Apr 2011 20:00:36 +0200 Subject: [PATCH] introduce and use __cdist_echo Signed-off-by: Nico Schottelius --- bin/cdist-config | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 96de4664..efb8c3c0 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -148,22 +148,37 @@ __cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX") ################################################################################ # Internal functions # -__cdist_debug_echo() +__cdist_echo() { - if [ "$__cdist_debug" ]; then - echo "Debug: $@" - fi + __cdist_echo_type="$1"; shift + + case "$__cdist_echo_type" in + debug) + if [ "$__cdist_debug" ]; then + echo "Debug: $@" + fi + ;; + info) + echo "$@" + ;; + error) + echo "Error: $@" >&2 + ;; + esac } __cdist_exec_fail_on_error() { 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() { - echo "Error: $@" >&2 + __cdist_echo error "$@" exit 1 }