From ea7df63ee59a31e3b5ea8b96352efaa2db0bfa5f Mon Sep 17 00:00:00 2001 From: Hugh Saunders Date: Wed, 9 Oct 2019 12:19:33 +0100 Subject: [PATCH 1/2] Retry command is evaluated Previously the command was directly executed, but that caused problems passing in compound statements. Related: conjurinc/ops#423 --- helpers/lib | 2 +- tests-for-this-repo/helpers.bats | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/helpers/lib b/helpers/lib index 6bea6e4..9606716 100644 --- a/helpers/lib +++ b/helpers/lib @@ -46,7 +46,7 @@ function retry { fi local count=0 - until "$@"; do + until eval "$@"; do # Command failed, otherwise until would have skipped the loop # Store return code so it can be reported to the user diff --git a/tests-for-this-repo/helpers.bats b/tests-for-this-repo/helpers.bats index bbea6f8..7750605 100644 --- a/tests-for-this-repo/helpers.bats +++ b/tests-for-this-repo/helpers.bats @@ -111,4 +111,8 @@ teardown(){ assert [ ! -e "${temp_dir}/appendfile" ] } - +@test "retry succeeds with compound statements" { + run retry 3 "true && date >> ${afile}" + assert_success + assert_equal $(wc -l <${afile}) 1 +} From 225232db60e95b5f94aaeb7b89db2e27cfafdae3 Mon Sep 17 00:00:00 2001 From: Hugh Saunders Date: Wed, 9 Oct 2019 12:48:19 +0100 Subject: [PATCH 2/2] Bash-Lib functions are exported to sub-shells This allows an initial script to source bash-lib/init and all functions be available to all sub scripts. Related: conjurinc/ops#423 --- init | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init b/init index e514598..6a6fff4 100644 --- a/init +++ b/init @@ -24,6 +24,9 @@ for lib in helpers logging filehandling git k8s test-utils; do . "${BASH_LIB_DIR_RELATIVE}/${lib}/lib" done +# Export functions to subshells +eval "$(declare -F | sed -e 's/-f /-fx /')" + # Export the absolute path # shellcheck disable=SC2086 BASH_LIB_DIR="$(abs_path ${BASH_LIB_DIR_RELATIVE})"