From 7f920d3c81f5b32c5fccea2b6c3f0e6d2e42c7d9 Mon Sep 17 00:00:00 2001 From: Paolo Salvatori Date: Wed, 4 Nov 2026 08:53:45 +0100 Subject: [PATCH] Run the file storage sample's scripts on macOS's bash 3.2 macOS ships bash 3.2 as /bin/bash. The ${value,,} and ${value^^} expansions need bash 4: under bash 3.2 they fail with "bad substitution" and the scripts carry on with empty values, for example an empty ACR name. The .NET and Python scripts now convert case with two small helpers in 00-variables.sh, lowercase and uppercase, which use tr and run on every bash. Co-Authored-By: Claude Opus 5.5 --- .../dotnet/scripts/00-variables.sh | 12 +++++++++++- .../dotnet/scripts/01-deploy-resources.sh | 6 +++--- .../dotnet/scripts/04-push-docker-image.sh | 4 ++-- .../dotnet/scripts/05-deploy-app.sh | 2 +- .../python/scripts/00-variables.sh | 12 +++++++++++- .../python/scripts/01-deploy-resources.sh | 6 +++--- .../python/scripts/04-push-docker-image.sh | 4 ++-- .../python/scripts/05-deploy-app.sh | 2 +- 8 files changed, 34 insertions(+), 14 deletions(-) diff --git a/samples/web-app-file-storage/dotnet/scripts/00-variables.sh b/samples/web-app-file-storage/dotnet/scripts/00-variables.sh index 938e702..f22632e 100755 --- a/samples/web-app-file-storage/dotnet/scripts/00-variables.sh +++ b/samples/web-app-file-storage/dotnet/scripts/00-variables.sh @@ -1,11 +1,21 @@ # Variables +# Lowercase and uppercase conversions that also run on bash 3.2, the /bin/bash of macOS: the +# ${value,,} and ${value^^} expansions need bash 4 and fail there with "bad substitution". +lowercase() { + printf '%s' "$1" | tr '[:upper:]' '[:lower:]' +} + +uppercase() { + printf '%s' "$1" | tr '[:lower:]' '[:upper:]' +} + # Azure Resources PREFIX='local' SUFFIX='test' LOCATION='italynorth' RESOURCE_GROUP_NAME="${PREFIX}-rg" -ACR_NAME="${PREFIX,,}acr${SUFFIX,,}" +ACR_NAME="$(lowercase "$PREFIX")acr$(lowercase "$SUFFIX")" ACR_SKU='Standard' AKS_CLUSTER_NAME="${PREFIX}-aks-${SUFFIX}" SUBSCRIPTION_NAME=$(az account show --query name --output tsv) diff --git a/samples/web-app-file-storage/dotnet/scripts/01-deploy-resources.sh b/samples/web-app-file-storage/dotnet/scripts/01-deploy-resources.sh index 68d94db..c951678 100755 --- a/samples/web-app-file-storage/dotnet/scripts/01-deploy-resources.sh +++ b/samples/web-app-file-storage/dotnet/scripts/01-deploy-resources.sh @@ -42,7 +42,7 @@ if [[ -z "$PROVISIONING_MODE" ]]; then done fi -PROVISIONING_MODE="${PROVISIONING_MODE,,}" +PROVISIONING_MODE="$(lowercase "$PROVISIONING_MODE")" if [[ "$PROVISIONING_MODE" != 'static' && "$PROVISIONING_MODE" != 'dynamic' ]]; then echo "Invalid provisioning mode [$PROVISIONING_MODE]: expected [static] or [dynamic]" @@ -80,7 +80,7 @@ if [[ -z "$FILE_SHARE_PROTOCOL" ]]; then done fi -FILE_SHARE_PROTOCOL="${FILE_SHARE_PROTOCOL,,}" +FILE_SHARE_PROTOCOL="$(lowercase "$FILE_SHARE_PROTOCOL")" if [[ "$FILE_SHARE_PROTOCOL" != 'smb' && "$FILE_SHARE_PROTOCOL" != 'nfs' ]]; then echo "Invalid file share protocol [$FILE_SHARE_PROTOCOL]: expected [smb] or [nfs]" @@ -104,7 +104,7 @@ else exit 1 fi -echo "Deploying the resources for [$PROVISIONING_MODE] provisioning over [${FILE_SHARE_PROTOCOL^^}]..." +echo "Deploying the resources for [$PROVISIONING_MODE] provisioning over [$(uppercase "$FILE_SHARE_PROTOCOL")]..." # Create a resource group echo "Checking if resource group [$RESOURCE_GROUP_NAME] exists in the subscription [$SUBSCRIPTION_NAME]..." diff --git a/samples/web-app-file-storage/dotnet/scripts/04-push-docker-image.sh b/samples/web-app-file-storage/dotnet/scripts/04-push-docker-image.sh index a1b7518..c9cdf75 100755 --- a/samples/web-app-file-storage/dotnet/scripts/04-push-docker-image.sh +++ b/samples/web-app-file-storage/dotnet/scripts/04-push-docker-image.sh @@ -20,7 +20,7 @@ fi FULL_IMAGE="${ACR_LOGIN_SERVER}/${IMAGE_NAME}:${IMAGE_TAG}" # Tag the local image with the loginServer of ACR -docker tag ${IMAGE_NAME,,}:$IMAGE_TAG $ACR_LOGIN_SERVER/${IMAGE_NAME,,}:$IMAGE_TAG +docker tag $(lowercase "$IMAGE_NAME"):$IMAGE_TAG $ACR_LOGIN_SERVER/$(lowercase "$IMAGE_NAME"):$IMAGE_TAG if [ $? -eq 0 ]; then echo "Docker image [$IMAGE_NAME] tagged as [$FULL_IMAGE] successfully." @@ -30,7 +30,7 @@ else fi # Push the container image to ACR -docker push $ACR_LOGIN_SERVER/${IMAGE_NAME,,}:$IMAGE_TAG +docker push $ACR_LOGIN_SERVER/$(lowercase "$IMAGE_NAME"):$IMAGE_TAG if [ $? -eq 0 ]; then echo "Docker image [$FULL_IMAGE] pushed to ACR successfully." diff --git a/samples/web-app-file-storage/dotnet/scripts/05-deploy-app.sh b/samples/web-app-file-storage/dotnet/scripts/05-deploy-app.sh index 2addd08..37422c8 100755 --- a/samples/web-app-file-storage/dotnet/scripts/05-deploy-app.sh +++ b/samples/web-app-file-storage/dotnet/scripts/05-deploy-app.sh @@ -26,7 +26,7 @@ if [[ "$FILE_SHARE_PROTOCOL" != 'smb' && "$FILE_SHARE_PROTOCOL" != 'nfs' ]]; the exit 1 fi -echo "Deploying the app with [$PROVISIONING_MODE] provisioning over [${FILE_SHARE_PROTOCOL^^}]..." +echo "Deploying the app with [$PROVISIONING_MODE] provisioning over [$(uppercase "$FILE_SHARE_PROTOCOL")]..." # Pick the storage account that holds the file share for the selected protocol if [[ "$FILE_SHARE_PROTOCOL" == 'nfs' ]]; then diff --git a/samples/web-app-file-storage/python/scripts/00-variables.sh b/samples/web-app-file-storage/python/scripts/00-variables.sh index 4138fe6..b84f0cb 100755 --- a/samples/web-app-file-storage/python/scripts/00-variables.sh +++ b/samples/web-app-file-storage/python/scripts/00-variables.sh @@ -1,11 +1,21 @@ # Variables +# Lowercase and uppercase conversions that also run on bash 3.2, the /bin/bash of macOS: the +# ${value,,} and ${value^^} expansions need bash 4 and fail there with "bad substitution". +lowercase() { + printf '%s' "$1" | tr '[:upper:]' '[:lower:]' +} + +uppercase() { + printf '%s' "$1" | tr '[:lower:]' '[:upper:]' +} + # Azure Resources PREFIX='local' SUFFIX='test' LOCATION='italynorth' RESOURCE_GROUP_NAME="${PREFIX}-rg" -ACR_NAME="${PREFIX,,}acr${SUFFIX,,}" +ACR_NAME="$(lowercase "$PREFIX")acr$(lowercase "$SUFFIX")" ACR_SKU='Standard' AKS_CLUSTER_NAME="${PREFIX}-aks-${SUFFIX}" SUBSCRIPTION_NAME=$(az account show --query name --output tsv) diff --git a/samples/web-app-file-storage/python/scripts/01-deploy-resources.sh b/samples/web-app-file-storage/python/scripts/01-deploy-resources.sh index 68d94db..c951678 100755 --- a/samples/web-app-file-storage/python/scripts/01-deploy-resources.sh +++ b/samples/web-app-file-storage/python/scripts/01-deploy-resources.sh @@ -42,7 +42,7 @@ if [[ -z "$PROVISIONING_MODE" ]]; then done fi -PROVISIONING_MODE="${PROVISIONING_MODE,,}" +PROVISIONING_MODE="$(lowercase "$PROVISIONING_MODE")" if [[ "$PROVISIONING_MODE" != 'static' && "$PROVISIONING_MODE" != 'dynamic' ]]; then echo "Invalid provisioning mode [$PROVISIONING_MODE]: expected [static] or [dynamic]" @@ -80,7 +80,7 @@ if [[ -z "$FILE_SHARE_PROTOCOL" ]]; then done fi -FILE_SHARE_PROTOCOL="${FILE_SHARE_PROTOCOL,,}" +FILE_SHARE_PROTOCOL="$(lowercase "$FILE_SHARE_PROTOCOL")" if [[ "$FILE_SHARE_PROTOCOL" != 'smb' && "$FILE_SHARE_PROTOCOL" != 'nfs' ]]; then echo "Invalid file share protocol [$FILE_SHARE_PROTOCOL]: expected [smb] or [nfs]" @@ -104,7 +104,7 @@ else exit 1 fi -echo "Deploying the resources for [$PROVISIONING_MODE] provisioning over [${FILE_SHARE_PROTOCOL^^}]..." +echo "Deploying the resources for [$PROVISIONING_MODE] provisioning over [$(uppercase "$FILE_SHARE_PROTOCOL")]..." # Create a resource group echo "Checking if resource group [$RESOURCE_GROUP_NAME] exists in the subscription [$SUBSCRIPTION_NAME]..." diff --git a/samples/web-app-file-storage/python/scripts/04-push-docker-image.sh b/samples/web-app-file-storage/python/scripts/04-push-docker-image.sh index a1b7518..c9cdf75 100755 --- a/samples/web-app-file-storage/python/scripts/04-push-docker-image.sh +++ b/samples/web-app-file-storage/python/scripts/04-push-docker-image.sh @@ -20,7 +20,7 @@ fi FULL_IMAGE="${ACR_LOGIN_SERVER}/${IMAGE_NAME}:${IMAGE_TAG}" # Tag the local image with the loginServer of ACR -docker tag ${IMAGE_NAME,,}:$IMAGE_TAG $ACR_LOGIN_SERVER/${IMAGE_NAME,,}:$IMAGE_TAG +docker tag $(lowercase "$IMAGE_NAME"):$IMAGE_TAG $ACR_LOGIN_SERVER/$(lowercase "$IMAGE_NAME"):$IMAGE_TAG if [ $? -eq 0 ]; then echo "Docker image [$IMAGE_NAME] tagged as [$FULL_IMAGE] successfully." @@ -30,7 +30,7 @@ else fi # Push the container image to ACR -docker push $ACR_LOGIN_SERVER/${IMAGE_NAME,,}:$IMAGE_TAG +docker push $ACR_LOGIN_SERVER/$(lowercase "$IMAGE_NAME"):$IMAGE_TAG if [ $? -eq 0 ]; then echo "Docker image [$FULL_IMAGE] pushed to ACR successfully." diff --git a/samples/web-app-file-storage/python/scripts/05-deploy-app.sh b/samples/web-app-file-storage/python/scripts/05-deploy-app.sh index a4772d3..f18a1f6 100755 --- a/samples/web-app-file-storage/python/scripts/05-deploy-app.sh +++ b/samples/web-app-file-storage/python/scripts/05-deploy-app.sh @@ -26,7 +26,7 @@ if [[ "$FILE_SHARE_PROTOCOL" != 'smb' && "$FILE_SHARE_PROTOCOL" != 'nfs' ]]; the exit 1 fi -echo "Deploying the app with [$PROVISIONING_MODE] provisioning over [${FILE_SHARE_PROTOCOL^^}]..." +echo "Deploying the app with [$PROVISIONING_MODE] provisioning over [$(uppercase "$FILE_SHARE_PROTOCOL")]..." # Pick the storage account that holds the file share for the selected protocol if [[ "$FILE_SHARE_PROTOCOL" == 'nfs' ]]; then