Skip to content

Fix examples/gateway/aws/setup.sh aborting on stock macOS bash 3.2 - #82320

Open
Yyunozor wants to merge 1 commit into
anthropics:mainfrom
Yyunozor:fix/gateway-setup-bash32
Open

Fix examples/gateway/aws/setup.sh aborting on stock macOS bash 3.2#82320
Yyunozor wants to merge 1 commit into
anthropics:mainfrom
Yyunozor:fix/gateway-setup-bash32

Conversation

@Yyunozor

Copy link
Copy Markdown

setup.sh line 66 uses ${DIST_SHA256,,}, a bash 4 case-modification
expansion. macOS ships bash 3.2 as /bin/bash, so unless a newer bash is
earlier on PATH, #!/usr/bin/env bash resolves to 3.2 and the script aborts
there — before reaching its own argument checks. The line is unconditional, so
it fires whether or not DIST_URL/DIST_SHA256 are set. bash -n passes; the
failure is runtime-only.

From the repo root on stock macOS:

$ /bin/bash examples/gateway/aws/setup.sh
examples/gateway/aws/setup.sh: line 66: ${DIST_SHA256,,}: bad substitution

The replacement lowercases the same digests with tr, pinned to LC_ALL=C so
BSD tr cannot fail the script on a stray non-UTF-8 byte under set -e. With
it, the same bash 3.2 run reaches the normal path and prints
ERROR: AWS_REGION is not set. The comment moves above the line to keep the
block's comment column.

This is the only bash 4 construct I found in the file; the GCP example next
door has none. Portability is already an explicit concern here — see the
sha_of() comment on line 127.

${DIST_SHA256,,} is a bash 4 case-modification expansion. macOS ships bash
3.2 as /bin/bash, so the line aborts the script with "bad substitution"
before it reaches its own argument checks. Replace it with printf | tr,
pinned to LC_ALL=C so BSD tr cannot fail the script on a stray non-UTF-8
byte under set -e.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant