Skip to content

Commit

Permalink
Replace use of rev for Windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Zordrak committed Dec 19, 2023
1 parent a14e553 commit 6f3d636
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libexec/tfenv-resolve-version
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fi;

if [[ "${version_requested}" =~ ^latest-allowed$ ]]; then
log 'debug' 'Detecting latest allowable version...';
version_spec="$(grep -h required_version "${TFENV_DIR:-$(pwd)}"/{*.tf,*.tf.json} 2>/dev/null | rev | cut -d'"' -f2 | rev | cut -d, -f1)";
version_spec="$(grep -h required_version "${TFENV_DIR:-$(pwd)}"/{*.tf,*.tf.json} 2>/dev/null | { IFS='"' read -r _ ver _; echo "${ver%%,*}"; })";
version_num="$(echo "${version_spec}" | sed -E 's/[^0-9.]+//')";
log 'debug' "Using ${version_num} from version spec: ${version_spec}";

Expand All @@ -141,7 +141,7 @@ if [[ "${version_requested}" =~ ^latest-allowed$ ]]; then
version_requested="${version_num}";
;;
'~>'*)
version_without_rightmost="$(echo "${version_num}" | rev | cut -d. -f2- | rev)";
version_without_rightmost="${version_num%.*}";
version_requested="latest:^${version_without_rightmost}";
;;
*)
Expand Down

0 comments on commit 6f3d636

Please sign in to comment.