'Why a function I am sourcing in bash not access the environment variables I have set? [duplicate]

I have some code that looks like this:

export AWS_REGION='us-east-1'
export CLUSTER_NAME='my_cluster'
export PROJECT_NAME='my_project'

source ./utils.sh

...additional functions...

annotate_cluster # comes from utils.sh

annotate_cluster, which comes from utils.sh, relies on the environment variable PROJECT_NAME. However, when I run it, it complains _utils.sh: line 60: FOO-${PROJECT_NAME^^}: bad substitution. Why can it not access the environment variable I have set?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source