diff --git a/HACKERS_README b/HACKERS_README index 7685ac35..aa3d937d 100755 --- a/HACKERS_README +++ b/HACKERS_README @@ -21,8 +21,10 @@ I usually do it like this: eof # Tell the user what we do, so this script makes sense during execution -# And abort on any error -set -ex +set -x + +# Abort on any error +set -e # prepare use (only from top level directory) export PATH="$PATH:$(pwd -P)/bin" diff --git a/bin/cdist-manifest-init b/bin/cdist-manifest-init index 7e3c0f2b..6a29ea9e 100755 --- a/bin/cdist-manifest-init +++ b/bin/cdist-manifest-init @@ -23,10 +23,8 @@ # . cdist-config - -if [ $# -ne 2 ]; then - __cdist_usage " " -fi +[ $# -eq 2 ] || __cdist_usage " " +set -e export __cdist_target_host="$1"; shift export __cdist_output_dir="$1"; shift diff --git a/bin/cdist-manifest-run b/bin/cdist-manifest-run index 98385ca8..72f01532 100755 --- a/bin/cdist-manifest-run +++ b/bin/cdist-manifest-run @@ -23,19 +23,15 @@ # . cdist-config - -if [ $# -ne 3 ]; then - __cdist_usage " " -fi - -set -aeu +[ $# -eq 3 ] || __cdist_usage " " +set -u export __cdist_target_host="$1"; shift export __cdist_manifest="$1"; shift export __cdist_output_dir="$1"; shift # Ensure binaries exist and are up-to-date -cdist-build-bin +cdist-build-bin || __cdist_exit_err "Failed to build support binaries" # prepend our path, so all cdist tools come before other tools PATH="${__cdist_cache_bin}:$PATH" @@ -50,7 +46,12 @@ mkdir -p "${__cdist_output_dir}" # Catch errors ourselves now set +e -"${__cdist_manifest}"; ret=$? +# 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 diff --git a/bin/cdist-object-codegen b/bin/cdist-object-codegen index 81357524..d2bdd550 100755 --- a/bin/cdist-object-codegen +++ b/bin/cdist-object-codegen @@ -56,7 +56,12 @@ eof # Catch errors ourself now set +e - "$gencode"; ret=$? + ( + # 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 diff --git a/conf/types/__file/gencode b/conf/types/__file/gencode index 0137064f..6fbafbe6 100755 --- a/conf/types/__file/gencode +++ b/conf/types/__file/gencode @@ -25,12 +25,15 @@ . cdist-config set -e +pwd -P >&2 +ls >&2 + type="$(cat type)" mode="$(cat mode)" path="$(cat path)" -case "$type" in +case "$type" in directory) echo mkdir \"$path\" ;;