Skip to content

Commit 66cea4c

Browse files
authored
Merge pull request #434 from fractos/fix/ignore-terraform-version-file-line-endings
Cope with different line endings in .terraform-version
2 parents 99b06bd + 08d328e commit 66cea4c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/tfenv-version-name.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function tfenv-version-name() {
1010
&& log 'debug' "TFENV_VERSION_FILE retrieved from tfenv-version-file: ${TFENV_VERSION_FILE}" \
1111
|| log 'error' 'Failed to retrieve TFENV_VERSION_FILE from tfenv-version-file';
1212

13-
TFENV_VERSION="$(cat "${TFENV_VERSION_FILE}" || true)" \
13+
TFENV_VERSION="$(cat "${TFENV_VERSION_FILE}" || true | tr -d '\r')" \
1414
&& log 'debug' "TFENV_VERSION specified in TFENV_VERSION_FILE: ${TFENV_VERSION}";
1515

1616
TFENV_VERSION_SOURCE="${TFENV_VERSION_FILE}";

libexec/tfenv-resolve-version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ if [ -z "${arg}" -a -z "${TFENV_TERRAFORM_VERSION:-""}" ]; then
7777

7878
if [ "${version_file}" != "${TFENV_CONFIG_DIR}/version" ]; then
7979
log 'debug' "Version File (${version_file}) is not the default \${TFENV_CONFIG_DIR}/version (${TFENV_CONFIG_DIR}/version)";
80-
version_requested="$(cat "${version_file}")" \
80+
version_requested="$(cat "${version_file}" | tr -d '\r')" \
8181
|| log 'error' "Failed to open ${version_file}";
8282

8383
elif [ -f "${version_file}" ]; then
8484
log 'debug' "Version File is the default \${TFENV_CONFIG_DIR}/version (${TFENV_CONFIG_DIR}/version)";
85-
version_requested="$(cat "${version_file}")" \
85+
version_requested="$(cat "${version_file}" | tr -d '\r')" \
8686
|| log 'error' "Failed to open ${version_file}";
8787

8888
# Absolute fallback

0 commit comments

Comments
 (0)