From 6740e4e398854a5d5281f645355739211a73032e Mon Sep 17 00:00:00 2001 From: Daniel Arroyo Date: Wed, 9 Sep 2026 11:26:35 -0300 Subject: [PATCH] fix: make SSH config directive matching case-insensitive resolve_ssh_alias() used a case statement that only matched 'HostName' (capital N), but OpenSSH treats config directives as case-insensitive: 'Hostname', 'HostName', 'HOSTNAME' and 'hostname' are all equivalent. A config like Host retailpos-hites-qa Hostname 10.60.16.35 User retailpos IdentityFile ~/.ssh/retailpos-key produced 'has no HostName' even though one was present. Enable 'shopt -s nocasematch' around the parsing loop so the case branches match any casing. nocasematch was chosen over ${var,,} because the latter requires bash 4+, and macOS still ships bash 3.2.57 as /bin/bash. The 'Host' pattern itself remains case-sensitive, matching ssh's own behavior. Verified against: tabbed/spaced/mixed indentation, lowercase, uppercase, mixed-casing directives, the user's exact config, and the previous regression cases. --- scripts/build-and-push.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/build-and-push.sh b/scripts/build-and-push.sh index a901c51..fc61487 100755 --- a/scripts/build-and-push.sh +++ b/scripts/build-and-push.sh @@ -134,6 +134,9 @@ resolve_ssh_alias() { local -a patterns # Force whitespace-aware splitting (the script's global IFS excludes spaces). local IFS=$' \t\n' + # SSH config directives are case-insensitive (HostName == Hostname == HOSTNAME). + # nocasematch is supported in bash 3.2 (unlike ${var,,} which needs 4+). + shopt -s nocasematch while read -r line || [[ -n "$line" ]]; do # First whitespace-separated token (tabs and spaces collapse uniformly). read -r first _ <<< "$line" @@ -163,6 +166,7 @@ resolve_ssh_alias() { esac fi done < "$config" + shopt -u nocasematch (( in_block )) \ || die "No matching Host entry in $config for alias '$alias'. Use user@host[:port] or check ~/.ssh/config."