From 4a6ec4fed7c1ca4e06e3f054ecf6950b33d6d0df Mon Sep 17 00:00:00 2001 From: A <258483684+la14-1@users.noreply.github.com> Date: Thu, 19 Feb 2026 14:49:35 -0800 Subject: [PATCH] fix: replace local -n namerefs in test/record.sh for bash 3.2 compat (#1488) Why: test/record.sh used local -n (bash 4.3+ namerefs) which crashes on macOS's default bash 3.2, breaking contributor workflow for recording API fixtures. Fixes #1480. Inlines the _export_env_vars_from_fields helper directly into _load_multi_config_from_file, eliminating the nameref dependency while preserving the security validation of env var names. Agent: team-lead Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 --- test/record.sh | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/test/record.sh b/test/record.sh index 95f25d22..73f40584 100644 --- a/test/record.sh +++ b/test/record.sh @@ -79,27 +79,6 @@ _get_multi_cred_spec() { esac } -# Extract and export environment variables from loaded data. -# Arguments: env_vars_array fields_array -# Tab-separated fields are exported to corresponding env vars with security validation. -_export_env_vars_from_fields() { - local -n env_vars_ref="$1" - local -n fields_ref="$2" - local i - - for i in "${!env_vars_ref[@]}"; do - if [[ -n "${fields_ref[$i]:-}" ]]; then - # SECURITY: Validate env var name before export - if [[ ! "${env_vars_ref[$i]}" =~ ^[A-Z_][A-Z0-9_]*$ ]]; then - echo "SECURITY: Invalid env var name rejected: ${env_vars_ref[$i]}" >&2 - return 1 - fi - export "${env_vars_ref[$i]}=${fields_ref[$i]}" - fi - done - return 0 -} - # Load multiple fields from a JSON config file and export as env vars. # Arguments: CONFIG_FILE SPEC... (each spec is "config_key:ENV_VAR") _load_multi_config_from_file() { @@ -127,7 +106,18 @@ except: pass local IFS=$'\t' local fields read -ra fields <<< "$vals" - _export_env_vars_from_fields env_vars fields + + local i + for i in "${!env_vars[@]}"; do + if [[ -n "${fields[$i]:-}" ]]; then + # SECURITY: Validate env var name before export + if [[ ! "${env_vars[$i]}" =~ ^[A-Z_][A-Z0-9_]*$ ]]; then + echo "SECURITY: Invalid env var name rejected: ${env_vars[$i]}" >&2 + return 1 + fi + export "${env_vars[$i]}=${fields[$i]}" + fi + done } # Save multiple env vars to a JSON config file.