From 0735b9e70eb8908121edbdc62aad6699d08ee73a Mon Sep 17 00:00:00 2001 From: bai <17348+bai@users.noreply.github.com> Date: Thu, 29 May 2025 10:57:20 +0300 Subject: [PATCH 01/11] The `hclfmt` command is no longer supported. Use `terragrunt hcl format` instead. --- hooks/terragrunt_fmt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hooks/terragrunt_fmt.sh b/hooks/terragrunt_fmt.sh index 698b3843b..a798eb0bd 100755 --- a/hooks/terragrunt_fmt.sh +++ b/hooks/terragrunt_fmt.sh @@ -12,7 +12,7 @@ function main { common::parse_cmdline "$@" common::export_provided_env_vars "${ENV_VARS[@]}" common::parse_and_export_env_vars - # JFYI: terragrunt hclfmt color already suppressed via PRE_COMMIT_COLOR=never + # JFYI: `terragrunt hcl format` color already suppressed via PRE_COMMIT_COLOR=never # shellcheck disable=SC2153 # False positive common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}" @@ -46,7 +46,7 @@ function per_dir_hook_unique_part { local -a -r args=("$@") # pass the arguments to hook - terragrunt hclfmt "${args[@]}" + terragrunt hcl format "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? @@ -63,7 +63,7 @@ function run_hook_on_whole_repo { local -a -r args=("$@") # pass the arguments to hook - terragrunt hclfmt "$(pwd)" "${args[@]}" + terragrunt hcl format "$(pwd)" "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? From fa91c5d0d1a5a88d8247a07c3d2112bce14bf573 Mon Sep 17 00:00:00 2001 From: bai <17348+bai@users.noreply.github.com> Date: Thu, 29 May 2025 15:31:42 +0300 Subject: [PATCH 02/11] Decide hclfmt vs hcl format based on terragrunt version --- hooks/terragrunt_fmt.sh | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/hooks/terragrunt_fmt.sh b/hooks/terragrunt_fmt.sh index a798eb0bd..de5c92250 100755 --- a/hooks/terragrunt_fmt.sh +++ b/hooks/terragrunt_fmt.sh @@ -7,6 +7,35 @@ readonly SCRIPT_DIR # shellcheck source=_common.sh . "$SCRIPT_DIR/_common.sh" +####################################################################### +# Get the appropriate terragrunt format command based on version +# Outputs: +# terragrunt format command (either "hclfmt" or "hcl format") +####################################################################### +function get_terragrunt_format_cmd { + local terragrunt_version + local major minor patch + + # Get terragrunt version, extract the version number + terragrunt_version=$(terragrunt --version 2>/dev/null | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+' | head -1 | sed 's/^v//') + + if [[ -z "$terragrunt_version" ]]; then + # If version detection fails, default to newer command + echo "hcl format" + return + fi + + # Parse version components + IFS='.' read -r major minor patch <<< "$terragrunt_version" + + # Compare version: if < 0.78, use hclfmt, otherwise use hcl format + if [[ $major -eq 0 && $minor -lt 78 ]]; then + echo "hclfmt" + else + echo "hcl format" + fi +} + function main { common::initialize "$SCRIPT_DIR" common::parse_cmdline "$@" @@ -45,8 +74,12 @@ function per_dir_hook_unique_part { shift 4 local -a -r args=("$@") + # Get the appropriate terragrunt format command + local format_cmd + format_cmd=$(get_terragrunt_format_cmd) + # pass the arguments to hook - terragrunt hcl format "${args[@]}" + terragrunt "$format_cmd" "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? @@ -62,8 +95,12 @@ function per_dir_hook_unique_part { function run_hook_on_whole_repo { local -a -r args=("$@") + # Get the appropriate terragrunt format command + local format_cmd + format_cmd=$(get_terragrunt_format_cmd) + # pass the arguments to hook - terragrunt hcl format "$(pwd)" "${args[@]}" + terragrunt "$format_cmd" "$(pwd)" "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? From f04a3ad288cbf2e686b59dad7ea61e227133fb19 Mon Sep 17 00:00:00 2001 From: MaxymVlasov Date: Thu, 29 May 2025 16:02:12 +0300 Subject: [PATCH 03/11] Make it more reusable and call check once Important PR description notes provided by Julien Rottenberg Co-authored-by: Julien Rottenberg --- hooks/_common.sh | 33 +++++++++++++++++++++++++++++ hooks/terragrunt_fmt.sh | 47 +++++++---------------------------------- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/hooks/_common.sh b/hooks/_common.sh index defc249a8..91eb5daa5 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -606,3 +606,36 @@ function common::export_provided_env_vars { export $var_name="$var_value" done } + +####################################################################### +# Check if the installed Terragrunt version is >=0.78.0 or not +# +# This function help to determine which terragrunt subcomand to use +# based on Terragrunt version +# +# Returns: +# - 0 if version >= 0.78.0 +# - 1 if version < 0.78.0 +# Defaults to 0 if version cannot be determined +####################################################################### +# TODO: Drop after May 2027. Two years to upgrade is more than enough. +function common::terragrunt_version_above_0.78 { + local terragrunt_version + + # Extract version number (e.g., "terragrunt version v0.80.4" -> "0.80") + terragrunt_version=$(terragrunt --version 2> /dev/null | grep -oE '[0-9]+\.[0-9]+') + # If we can't parse version, default to newer command + if [[ -z "$terragrunt_version" ]]; then + return 0 + fi + + local major minor + IFS='.' read -r major minor <<< "$terragrunt_version" + + # `hcl format` support added in v0.78.0 (May 2025) + if [[ $major -gt 0 ]] || [[ $major -eq 0 && $minor -ge 78 ]]; then + return 0 + else + return 1 + fi +} diff --git a/hooks/terragrunt_fmt.sh b/hooks/terragrunt_fmt.sh index de5c92250..9668f38de 100755 --- a/hooks/terragrunt_fmt.sh +++ b/hooks/terragrunt_fmt.sh @@ -7,35 +7,6 @@ readonly SCRIPT_DIR # shellcheck source=_common.sh . "$SCRIPT_DIR/_common.sh" -####################################################################### -# Get the appropriate terragrunt format command based on version -# Outputs: -# terragrunt format command (either "hclfmt" or "hcl format") -####################################################################### -function get_terragrunt_format_cmd { - local terragrunt_version - local major minor patch - - # Get terragrunt version, extract the version number - terragrunt_version=$(terragrunt --version 2>/dev/null | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+' | head -1 | sed 's/^v//') - - if [[ -z "$terragrunt_version" ]]; then - # If version detection fails, default to newer command - echo "hcl format" - return - fi - - # Parse version components - IFS='.' read -r major minor patch <<< "$terragrunt_version" - - # Compare version: if < 0.78, use hclfmt, otherwise use hcl format - if [[ $major -eq 0 && $minor -lt 78 ]]; then - echo "hclfmt" - else - echo "hcl format" - fi -} - function main { common::initialize "$SCRIPT_DIR" common::parse_cmdline "$@" @@ -43,6 +14,12 @@ function main { common::parse_and_export_env_vars # JFYI: `terragrunt hcl format` color already suppressed via PRE_COMMIT_COLOR=never + if common::terragrunt_version_above_0.78; then + readonly SUBCOMMAND="hcl format" + else + readonly SUBCOMMAND="hclfmt" + fi + # shellcheck disable=SC2153 # False positive common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}" } @@ -74,12 +51,8 @@ function per_dir_hook_unique_part { shift 4 local -a -r args=("$@") - # Get the appropriate terragrunt format command - local format_cmd - format_cmd=$(get_terragrunt_format_cmd) - # pass the arguments to hook - terragrunt "$format_cmd" "${args[@]}" + terragrunt "$SUBCOMMAND" "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? @@ -95,12 +68,8 @@ function per_dir_hook_unique_part { function run_hook_on_whole_repo { local -a -r args=("$@") - # Get the appropriate terragrunt format command - local format_cmd - format_cmd=$(get_terragrunt_format_cmd) - # pass the arguments to hook - terragrunt "$format_cmd" "$(pwd)" "${args[@]}" + terragrunt "$SUBCOMMAND" "$(pwd)" "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? From bd44970eb0baf86f63d57c11d6105cb8fa0768ed Mon Sep 17 00:00:00 2001 From: MaxymVlasov Date: Thu, 29 May 2025 16:12:54 +0300 Subject: [PATCH 04/11] Address expansion issue --- hooks/terragrunt_fmt.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hooks/terragrunt_fmt.sh b/hooks/terragrunt_fmt.sh index 9668f38de..3d6508e9c 100755 --- a/hooks/terragrunt_fmt.sh +++ b/hooks/terragrunt_fmt.sh @@ -15,9 +15,9 @@ function main { # JFYI: `terragrunt hcl format` color already suppressed via PRE_COMMIT_COLOR=never if common::terragrunt_version_above_0.78; then - readonly SUBCOMMAND="hcl format" + readonly SUBCOMMAND=(hcl format) else - readonly SUBCOMMAND="hclfmt" + readonly SUBCOMMAND=(hclfmt) fi # shellcheck disable=SC2153 # False positive @@ -52,7 +52,7 @@ function per_dir_hook_unique_part { local -a -r args=("$@") # pass the arguments to hook - terragrunt "$SUBCOMMAND" "${args[@]}" + terragrunt "${SUBCOMMAND[@]}" "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? @@ -69,7 +69,7 @@ function run_hook_on_whole_repo { local -a -r args=("$@") # pass the arguments to hook - terragrunt "$SUBCOMMAND" "$(pwd)" "${args[@]}" + terragrunt "${SUBCOMMAND[@]}" "$(pwd)" "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? From 127f3f9e9dc7ac2a11bbae21a2e9625da9302993 Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Thu, 29 May 2025 16:26:20 +0300 Subject: [PATCH 05/11] Apply suggestions from code review --- hooks/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/_common.sh b/hooks/_common.sh index 91eb5daa5..f06d0e32f 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -632,7 +632,7 @@ function common::terragrunt_version_above_0.78 { local major minor IFS='.' read -r major minor <<< "$terragrunt_version" - # `hcl format` support added in v0.78.0 (May 2025) + # New subcommands added in v0.78.0 (May 2025) if [[ $major -gt 0 ]] || [[ $major -eq 0 && $minor -ge 78 ]]; then return 0 else From cdc4559d73f1feac3d624b1b49240c0860af20a3 Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Thu, 29 May 2025 16:32:43 +0300 Subject: [PATCH 06/11] Apply suggestions from code review Co-authored-by: George L. Yermulnik --- hooks/_common.sh | 7 +++---- hooks/terragrunt_fmt.sh | 7 ++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/hooks/_common.sh b/hooks/_common.sh index f06d0e32f..f00f27328 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -610,7 +610,7 @@ function common::export_provided_env_vars { ####################################################################### # Check if the installed Terragrunt version is >=0.78.0 or not # -# This function help to determine which terragrunt subcomand to use +# This function helps to determine which terragrunt subcomand to use # based on Terragrunt version # # Returns: @@ -619,14 +619,13 @@ function common::export_provided_env_vars { # Defaults to 0 if version cannot be determined ####################################################################### # TODO: Drop after May 2027. Two years to upgrade is more than enough. -function common::terragrunt_version_above_0.78 { +function common::terragrunt_version_ge_0.78 { local terragrunt_version # Extract version number (e.g., "terragrunt version v0.80.4" -> "0.80") terragrunt_version=$(terragrunt --version 2> /dev/null | grep -oE '[0-9]+\.[0-9]+') # If we can't parse version, default to newer command - if [[ -z "$terragrunt_version" ]]; then - return 0 + [[ ! $terragrunt_version ]] && return 0 fi local major minor diff --git a/hooks/terragrunt_fmt.sh b/hooks/terragrunt_fmt.sh index 3d6508e9c..2ca003ea6 100755 --- a/hooks/terragrunt_fmt.sh +++ b/hooks/terragrunt_fmt.sh @@ -14,11 +14,8 @@ function main { common::parse_and_export_env_vars # JFYI: `terragrunt hcl format` color already suppressed via PRE_COMMIT_COLOR=never - if common::terragrunt_version_above_0.78; then - readonly SUBCOMMAND=(hcl format) - else - readonly SUBCOMMAND=(hclfmt) - fi + readonly SUBCOMMAND + common::terragrunt_version_ge_0.78 && SUBCOMMAND=(hcl format) || SUBCOMMAND=(hclfmt) # shellcheck disable=SC2153 # False positive common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}" From c39c94b756c956608901f7a503222d0bc778cc53 Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Thu, 29 May 2025 16:34:00 +0300 Subject: [PATCH 07/11] Change if notation to more concictent accross codebase Co-authored-by: George L. Yermulnik --- hooks/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/_common.sh b/hooks/_common.sh index f00f27328..37ab3de7a 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -632,7 +632,7 @@ function common::terragrunt_version_ge_0.78 { IFS='.' read -r major minor <<< "$terragrunt_version" # New subcommands added in v0.78.0 (May 2025) - if [[ $major -gt 0 ]] || [[ $major -eq 0 && $minor -ge 78 ]]; then + if [[ $major -gt 0 || ($major -eq 0 && $minor -ge 78) ]]; then return 0 else return 1 From 25f4370bd1b8cca79bc7f5f9543442c9a1725dc3 Mon Sep 17 00:00:00 2001 From: bai <17348+bai@users.noreply.github.com> Date: Thu, 29 May 2025 17:16:01 +0300 Subject: [PATCH 08/11] Handle validate-inputs --- hooks/terragrunt_validate_inputs.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hooks/terragrunt_validate_inputs.sh b/hooks/terragrunt_validate_inputs.sh index 0c8d79e2d..41212ad40 100755 --- a/hooks/terragrunt_validate_inputs.sh +++ b/hooks/terragrunt_validate_inputs.sh @@ -14,6 +14,16 @@ function main { common::parse_and_export_env_vars # JFYI: terragrunt validate color already suppressed via PRE_COMMIT_COLOR=never + readonly SUBCOMMAND + readonly RUN_ALL_SUBCOMMAND + if common::terragrunt_version_ge_0.78; then + SUBCOMMAND=(hcl validate --inputs) + RUN_ALL_SUBCOMMAND=(run --all hcl validate --inputs) + else + SUBCOMMAND=(validate-inputs) + RUN_ALL_SUBCOMMAND=(run-all validate-inputs) + fi + # shellcheck disable=SC2153 # False positive common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}" } @@ -46,7 +56,7 @@ function per_dir_hook_unique_part { local -a -r args=("$@") # pass the arguments to hook - terragrunt validate-inputs "${args[@]}" + terragrunt "${SUBCOMMAND[@]}" "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? @@ -63,7 +73,7 @@ function run_hook_on_whole_repo { local -a -r args=("$@") # pass the arguments to hook - terragrunt run-all validate-inputs "${args[@]}" + terragrunt "${RUN_ALL_SUBCOMMAND[@]}" "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? From 0d10a11a02501fe8025c90f8ef8df6da66204af5 Mon Sep 17 00:00:00 2001 From: bai <17348+bai@users.noreply.github.com> Date: Thu, 29 May 2025 17:22:38 +0300 Subject: [PATCH 09/11] Handle run-all/run --all --- hooks/terragrunt_providers_lock.sh | 9 ++++++++- hooks/terragrunt_validate.sh | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/hooks/terragrunt_providers_lock.sh b/hooks/terragrunt_providers_lock.sh index 9e3557aeb..89a2edc84 100755 --- a/hooks/terragrunt_providers_lock.sh +++ b/hooks/terragrunt_providers_lock.sh @@ -14,6 +14,13 @@ function main { common::parse_and_export_env_vars # JFYI: terragrunt providers lock color already suppressed via PRE_COMMIT_COLOR=never + readonly RUN_ALL_SUBCOMMAND + if common::terragrunt_version_ge_0.78; then + RUN_ALL_SUBCOMMAND=(run --all providers lock) + else + RUN_ALL_SUBCOMMAND=(run-all providers lock) + fi + # shellcheck disable=SC2153 # False positive common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}" } @@ -63,7 +70,7 @@ function run_hook_on_whole_repo { local -a -r args=("$@") # pass the arguments to hook - terragrunt run-all providers lock "${args[@]}" + terragrunt "${RUN_ALL_SUBCOMMAND[@]}" "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? diff --git a/hooks/terragrunt_validate.sh b/hooks/terragrunt_validate.sh index 5a62c3913..3086a8583 100755 --- a/hooks/terragrunt_validate.sh +++ b/hooks/terragrunt_validate.sh @@ -14,6 +14,13 @@ function main { common::parse_and_export_env_vars # JFYI: terragrunt validate color already suppressed via PRE_COMMIT_COLOR=never + readonly RUN_ALL_SUBCOMMAND + if common::terragrunt_version_ge_0.78; then + RUN_ALL_SUBCOMMAND=(run --all validate) + else + RUN_ALL_SUBCOMMAND=(run-all validate) + fi + # shellcheck disable=SC2153 # False positive common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}" } @@ -63,7 +70,7 @@ function run_hook_on_whole_repo { local -a -r args=("$@") # pass the arguments to hook - terragrunt run-all validate "${args[@]}" + terragrunt "${RUN_ALL_SUBCOMMAND[@]}" "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? From 346b177a0019ce26a9cc907ce5d72016998b9cdd Mon Sep 17 00:00:00 2001 From: bai <17348+bai@users.noreply.github.com> Date: Thu, 29 May 2025 17:28:25 +0300 Subject: [PATCH 10/11] Remove oopsie --- hooks/_common.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/hooks/_common.sh b/hooks/_common.sh index 37ab3de7a..7281b0244 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -626,7 +626,6 @@ function common::terragrunt_version_ge_0.78 { terragrunt_version=$(terragrunt --version 2> /dev/null | grep -oE '[0-9]+\.[0-9]+') # If we can't parse version, default to newer command [[ ! $terragrunt_version ]] && return 0 - fi local major minor IFS='.' read -r major minor <<< "$terragrunt_version" From 66dc2737de3701e476c42587101e1e4dd57b7a58 Mon Sep 17 00:00:00 2001 From: MaxymVlasov Date: Thu, 29 May 2025 17:47:43 +0300 Subject: [PATCH 11/11] fix "readonly" --- hooks/terragrunt_fmt.sh | 7 +++++-- hooks/terragrunt_providers_lock.sh | 5 ++--- hooks/terragrunt_validate.sh | 5 ++--- hooks/terragrunt_validate_inputs.sh | 10 ++++------ 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/hooks/terragrunt_fmt.sh b/hooks/terragrunt_fmt.sh index 2ca003ea6..2d6697ae3 100755 --- a/hooks/terragrunt_fmt.sh +++ b/hooks/terragrunt_fmt.sh @@ -14,8 +14,11 @@ function main { common::parse_and_export_env_vars # JFYI: `terragrunt hcl format` color already suppressed via PRE_COMMIT_COLOR=never - readonly SUBCOMMAND - common::terragrunt_version_ge_0.78 && SUBCOMMAND=(hcl format) || SUBCOMMAND=(hclfmt) + if common::terragrunt_version_ge_0.78; then + local -ra SUBCOMMAND=(hcl format) + else + local -ra SUBCOMMAND=(hclfmt) + fi # shellcheck disable=SC2153 # False positive common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}" diff --git a/hooks/terragrunt_providers_lock.sh b/hooks/terragrunt_providers_lock.sh index 89a2edc84..21ee668fe 100755 --- a/hooks/terragrunt_providers_lock.sh +++ b/hooks/terragrunt_providers_lock.sh @@ -14,11 +14,10 @@ function main { common::parse_and_export_env_vars # JFYI: terragrunt providers lock color already suppressed via PRE_COMMIT_COLOR=never - readonly RUN_ALL_SUBCOMMAND if common::terragrunt_version_ge_0.78; then - RUN_ALL_SUBCOMMAND=(run --all providers lock) + local -ra RUN_ALL_SUBCOMMAND=(run --all providers lock) else - RUN_ALL_SUBCOMMAND=(run-all providers lock) + local -ra RUN_ALL_SUBCOMMAND=(run-all providers lock) fi # shellcheck disable=SC2153 # False positive diff --git a/hooks/terragrunt_validate.sh b/hooks/terragrunt_validate.sh index 3086a8583..54b7a98d6 100755 --- a/hooks/terragrunt_validate.sh +++ b/hooks/terragrunt_validate.sh @@ -14,11 +14,10 @@ function main { common::parse_and_export_env_vars # JFYI: terragrunt validate color already suppressed via PRE_COMMIT_COLOR=never - readonly RUN_ALL_SUBCOMMAND if common::terragrunt_version_ge_0.78; then - RUN_ALL_SUBCOMMAND=(run --all validate) + local -ra RUN_ALL_SUBCOMMAND=(run --all validate) else - RUN_ALL_SUBCOMMAND=(run-all validate) + local -ra RUN_ALL_SUBCOMMAND=(run-all validate) fi # shellcheck disable=SC2153 # False positive diff --git a/hooks/terragrunt_validate_inputs.sh b/hooks/terragrunt_validate_inputs.sh index 41212ad40..39e8e484e 100755 --- a/hooks/terragrunt_validate_inputs.sh +++ b/hooks/terragrunt_validate_inputs.sh @@ -14,14 +14,12 @@ function main { common::parse_and_export_env_vars # JFYI: terragrunt validate color already suppressed via PRE_COMMIT_COLOR=never - readonly SUBCOMMAND - readonly RUN_ALL_SUBCOMMAND if common::terragrunt_version_ge_0.78; then - SUBCOMMAND=(hcl validate --inputs) - RUN_ALL_SUBCOMMAND=(run --all hcl validate --inputs) + local -ra SUBCOMMAND=(hcl validate --inputs) + local -ra RUN_ALL_SUBCOMMAND=(run --all hcl validate --inputs) else - SUBCOMMAND=(validate-inputs) - RUN_ALL_SUBCOMMAND=(run-all validate-inputs) + local -ra SUBCOMMAND=(validate-inputs) + local -ra RUN_ALL_SUBCOMMAND=(run-all validate-inputs) fi # shellcheck disable=SC2153 # False positive