You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,7 +81,7 @@ $ which tfenv
81
81
82
82
Install a specific version of Terraform.
83
83
84
-
If no parameter is passed, the version to use is resolved automatically via [.terraform-version files](#terraform-version-file) or [TFENV\_TERRAFORM\_VERSION environment variable](#tfenv_terraform_version) (TFENV\_TERRAFORM\_VERSION takes precedence), defaulting to 'latest' if none are found.
84
+
If no parameter is passed, the version to use is resolved automatically via [TFENV\_TERRAFORM\_VERSION environment variable](#tfenv_terraform_version), [.terraform-version files](#terraform-version-file), or [required_version in "terraform" section of any .tf or .tf.json file](#min-required), in that order of precedence, i.e. TFENV\_TERRAFORM\_VERSION, then .terraform-version, and then required_version in .tf. The default is 'latest' if none are found.
if [ -z"${version_requested}"-a-f"${version_file}" ];then
80
103
log 'debug'"Version File is the default \${TFENV_CONFIG_DIR}/version (${TFENV_CONFIG_DIR}/version)";
81
104
version_requested="$(cat "${version_file}")" \
82
105
|| log 'error'"Failed to open ${version_file}";
83
106
84
-
# Absolute fallback
85
107
if [ -z"${version_requested}" ];then
86
108
log 'debug''Version file had no content. Falling back to "latest"';
87
109
version_requested='latest';
88
110
fi;
89
111
90
-
else
112
+
# Absolute fallback
113
+
elif [ -z"${version_requested}" ];then
91
114
log 'debug'"Version File is the default \${TFENV_CONFIG_DIR}/version (${TFENV_CONFIG_DIR}/version) but it doesn't exist";
92
115
log 'info''No version requested on the command line or in the version file search path. Installing "latest"';
93
116
version_requested='latest';
@@ -123,7 +146,7 @@ resolve_version () {
123
146
regex="^${version_requested}$";
124
147
log 'debug'"Version is explicit: ${version}. Regex enforces the version: ${regex}";
125
148
fi;
126
-
}
149
+
};
127
150
128
151
# Curl wrapper to switch TLS option for each OS
129
152
functioncurlw () {
@@ -141,13 +164,13 @@ function curlw () {
141
164
fi;
142
165
143
166
curl ${TLS_OPT}${NETRC_OPT}"$@";
144
-
}
167
+
};
145
168
export -f curlw;
146
169
147
170
check_active_version() {
148
171
local v="${1}";
149
172
[ -n"$(${TFENV_ROOT}/bin/terraform version | grep -E "^Terraform v${v}((-dev)|( \([a-f0-9]+\)))?$")" ];
150
-
}
173
+
};
151
174
export -f check_active_version;
152
175
153
176
check_installed_version() {
@@ -173,6 +196,8 @@ cleanup() {
173
196
rm -rf ./.terraform-version;
174
197
log 'debug'"Deleting ${pwd}/min_required.tf";
175
198
rm -rf ./min_required.tf;
199
+
log 'debug'"Deleting ${pwd}/required_version.tf";
200
+
rm -rf ./required_version.tf;
176
201
};
177
202
export -f cleanup;
178
203
@@ -182,6 +207,18 @@ function error_and_proceed() {
182
207
};
183
208
export -f error_and_proceed;
184
209
210
+
functioncheck_dependencies() {
211
+
if [[ $(uname)=='Darwin' ]] && [ $(which brew) ];then
212
+
if! [ $(which ggrep) ];then
213
+
log 'error''A metaphysical dichotomy has caused this unit to overload and shut down. GNU Grep is a requirement and your Mac does not have it. Consider "brew install grep"';
0 commit comments