Skip to content

Commit ec30be8

Browse files
committed
Fix operator precedence bug and unbound variable in tfenv-version-name.sh
Fix #406: Replace undefined ${requested} variable with ${TFENV_VERSION} in the error message on line 82. The variable was introduced in commit 3dc5819 but never existed in scope, causing an unbound variable crash under set -u before the error message could be displayed. Fix #431: Fix shell operator precedence in the version file read on line 13. The original "cat ... || true | tr" meant tr only ran on the failure path due to || binding tighter than |. Restructured to "cat ... | tr ... || true" so carriage returns are always stripped. Also addresses #447 (WSL carriage return symptoms) which shares the same root cause as #431.
1 parent fa8d238 commit ec30be8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/tfenv-version-name.sh

Lines changed: 2 additions & 2 deletions
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 | tr -d '\r')" \
13+
TFENV_VERSION="$(cat "${TFENV_VERSION_FILE}" | tr -d '\r' || true)" \
1414
&& log 'debug' "TFENV_VERSION specified in TFENV_VERSION_FILE: ${TFENV_VERSION}";
1515

1616
TFENV_VERSION_SOURCE="${TFENV_VERSION_FILE}";
@@ -77,7 +77,7 @@ function tfenv-version-name() {
7777
TFENV_VERSION="${local_version}";
7878
fi;
7979
else
80-
log 'error' "No versions matching '${requested}' found in remote";
80+
log 'error' "No versions matching '${TFENV_VERSION}' found in remote";
8181
fi;
8282
else
8383
if [[ -n "${local_version}" ]]; then

0 commit comments

Comments
 (0)