diff --git a/libexec/tofuenv-pin b/libexec/tofuenv-pin index a61d8d0..3d9a53c 100755 --- a/libexec/tofuenv-pin +++ b/libexec/tofuenv-pin @@ -71,7 +71,11 @@ done; version_name="$(tofuenv-version-name 2>/dev/null || true)" \ && log 'debug' "tofuenv-version-name reported: ${version_name}"; -echo "${version_name}" > .opentofu-version; -log 'info' "Pinned version by writing \"${version_name}\" to $(pwd)/.opentofu-version"; +if [ -n "${version_name}" ]; then + echo "${version_name}" > .opentofu-version; + log 'info' "Pinned version by writing \"${version_name}\" to $(pwd)/.opentofu-version"; +else + log 'error' "No version is currently used. Please first set one with: tofuenv use" +fi; exit 0;