mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2026-06-15 13:06:54 +02:00
fix(hooks): make env var regex portable
Adjust the regex used to detect ${ENV_VAR} patterns in
hooks/_common.sh to avoid Bash-incompatible constructs and to be
compatible with macOS/BSD regex behavior.
- Remove unnecessary leading/trailing '.*' since =~ matches substrings.
- Allow lowercase letters in subsequent identifier characters
([A-Za-z0-9_]) so variable names with lowercase chars are detected.
- Keep first-char restriction to uppercase or underscore to match
existing extraction logic.
Signed-off-by: Michael Rosenfeld <mrosenfe@sheetz.com>
This commit is contained in:
parent
7067827cf3
commit
caab3b8701
1 changed files with 1 additions and 1 deletions
|
|
@ -112,7 +112,7 @@ function common::parse_and_export_env_vars {
|
|||
while true; do
|
||||
# Check if at least 1 env var exists in `$arg`
|
||||
# shellcheck disable=SC2016 # '${' should not be expanded
|
||||
if [[ "$arg" =~ .*'${'[A-Z_][A-Z0-9_]*'}'.* ]]; then
|
||||
if [[ "$arg" =~ '${'[A-Z_][A-Za-z0-9_]*'}' ]]; then
|
||||
# Get `ENV_VAR` from `.*${ENV_VAR}.*`
|
||||
local env_var_name=${arg#*$\{}
|
||||
env_var_name=${env_var_name%%\}*}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue