From 5dcb719844fefbd2881f0482584e51f6720dcdd5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 22 Feb 2011 11:39:23 +0100 Subject: [PATCH] introduce and use __cdist_exec_fail_on_error Signed-off-by: Nico Schottelius --- bin/cdist-config | 3 ++- bin/cdist-manifest-run | 15 ++------------- bin/cdist-object-codegen | 16 +--------------- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 445c5b32..3a57e56e 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -181,7 +181,8 @@ __cdist_object_source() __cdist_exec_fail_on_error() { - sh -e "$1" + sh -e "$@" + [ "$?" -eq 0 ] || __cdist_exit_err "Error: $1 exited non-zero." } diff --git a/bin/cdist-manifest-run b/bin/cdist-manifest-run index 72f01532..38cf9f1b 100755 --- a/bin/cdist-manifest-run +++ b/bin/cdist-manifest-run @@ -41,17 +41,6 @@ if [ ! -x "${__cdist_manifest}" ]; then __cdist_exit_err "${__cdist_manifest} needs to be executable." fi -mkdir -p "${__cdist_output_dir}" +mkdir -p "${__cdist_output_dir}" || __cdist_exit_err "Cannot create output dir ${__cdist_output_dir}" -# Catch errors ourselves now -set +e - -# Ensure manifest fails if any error exists - FIXME: redundant, cdist-object-codegen -( - set -e - . "${__cdist_manifest}" -); ret=$? - -if [ "$ret" -ne 0 ]; then - __cdist_exit_err "Error: ${__cdist_manifest} exited non-zero." -fi +__cdist_exec_fail_on_error "${__cdist_manifest}" diff --git a/bin/cdist-object-codegen b/bin/cdist-object-codegen index d2bdd550..52006255 100755 --- a/bin/cdist-object-codegen +++ b/bin/cdist-object-codegen @@ -54,19 +54,5 @@ if [ -x "$gencode" ]; then eof - # Catch errors ourself now - set +e - ( - # Ensure manifest fails if something within manifest fails - # And not all manifests need to include set -e themselves - set -e - . "$gencode" - ); ret=$? - -else - ret=0 -fi - -if [ "$ret" -ne 0 ]; then - __cdist_exit_err "Error: $gencode exited non-zero" + __cdist_exec_fail_on_error "$gencode" fi