diff --git a/tff b/tff index cf6907775cbf5db5213d7871b60fff93642d26e2..f0a49985a9a6e99a118560227d70a59d96c31d8d 100755 --- a/tff +++ b/tff @@ -3,7 +3,10 @@ set -eu command -v terraform >/dev/null || { echo "Can't find the terraform binary, aborting." >&2; exit 1; } +original_pwd="$PWD" for i in "$@" do - terraform fmt "$(dirname "$i")" || true + cd "$(dirname "$i")" + terraform fmt || true + cd "$original_pwd" done diff --git a/tfv b/tfv index 5d9f1b67f66e158fd0dc3aefe8b68e62d30e597c..dbc861eacd4c44626434b108e37e7a962491ef4a 100755 --- a/tfv +++ b/tfv @@ -6,10 +6,13 @@ command -v terraform >/dev/null || { echo "Can't find the terraform binary, abor export TF_INPUT='0' export TF_IN_AUTOMATION='1' +original_pwd="$PWD" for i in "$@" do - terraform init -backend=false "$(dirname "$i")" || { code='1'; continue; } - terraform validate "$(dirname "$i")" || code='1' + cd "$(dirname "$i")" + terraform init -backend=false || { code='1'; continue; } + terraform validate || code='1' + cd "$original_pwd" done exit "${code:-0}"