Repository: gruntwork-io/terragrunt (language: go)

Issue:
Simplify / Tighten regex in terraform version check
**Describe the solution you'd like**
When debugging a separate issue, I noticed that the regex for the terraform version check is fairly loose, and includes a trailing `.*` that I believe should be redundant.

[Already created a PR, but see that an issue should be created]

**Describe alternatives you've considered**
I could also tighten it further by using something like `Terraform|OpenTofu` or `\w+` instead of `\S+`. If you don't feel it's an issue, feel free to close this issue and my PR.

**Additional context**
- #2745
- #2817 



Discussion / hints:

Fix patch:
diff --git a/cli/commands/terraform/version_check.go b/cli/commands/terraform/version_check.go
index 40d78a6764..4eab4af248 100644
--- a/cli/commands/terraform/version_check.go
+++ b/cli/commands/terraform/version_check.go
@@ -18,11 +18,12 @@ import (
 const DefaultTerraformVersionConstraint = ">= v0.12.0"
 
 // TerraformVersionRegex verifies that terraform --version output is in one of the following formats:
+// - OpenTofu v1.6.0-dev
 // - Terraform v0.9.5-dev (cad024a5fe131a546936674ef85445215bbc4226+CHANGES)
 // - Terraform v0.13.0-beta2
 // - Terraform v0.12.27
 // We only make sure the "v#.#.#" part is present in the output.
-var TerraformVersionRegex = regexp.MustCompile(`^(.*?)\s(v?\d+\.\d+\.\d+).*`)
+var TerraformVersionRegex = regexp.MustCompile(`^(\S+)\s(v?\d+\.\d+\.\d+)`)
 
 const versionParts = 3
 


Test patch:
diff --git a/cli/commands/terraform/version_check_test.go b/cli/commands/terraform/version_check_test.go
index 27d90fc300..7d4988b602 100644
--- a/cli/commands/terraform/version_check_test.go
+++ b/cli/commands/terraform/version_check_test.go
@@ -35,6 +35,16 @@ func TestCheckTerraformVersionMeetsConstraintLessMajor(t *testing.T) {
 	testCheckTerraformVersionMeetsConstraint(t, "v0.8.8", ">= v0.9.3", false)
 }
 
+func TestParseOpenTofuVersionNormal(t *testing.T) {
+	t.Parallel()
+	testParseTerraformVersion(t, "OpenTofu v1.6.0", "v1.6.0", nil)
+}
+
+func TestParseOpenTofuVersionDev(t *testing.T) {
+	t.Parallel()
+	testParseTerraformVersion(t, "OpenTofu v1.6.0-dev", "v1.6.0", nil)
+}
+
 func TestParseTerraformVersionNormal(t *testing.T) {
 	t.Parallel()
 	testParseTerraformVersion(t, "Terraform v0.9.3", "v0.9.3", nil)