I have a script called render.sh that looks like this:
#!/usr/bin/env bash
if [[ -f "${ENVIRONMENT}.yaml" ]]; then
ENV_YAML="-f ${ENVIRONMENT}.yaml"
fi
set -x
helm3 template "$SERVICE_NAME" . --namespace="$NAMESPACE" \
${ENV_YAML:-} \
--set environment="$ENVIRONMENT"
It's sourced in a larger script twice:
SERVICE_NAME=a
NAMESPACE=b
ENVIRONMENT=foo
source render.sh
# other code
SERVICE_NAME=a
NAMESPACE=b
ENVIRONMENT=bar
source render.sh
The output looks like this:
++ helm3 template a . --namespace=b -f foo.yaml --set environment=foo
...
++ helm3 template a . --namespace=b '-f bar.yaml' --set environment=bar
In the second execution, something is adding quotes. I know bash has a few different ways of automatically adding quotes like ${VAR@Q} and "$@", but none of them seem to be in use.
Is there a mode in bash that would automatically add quotes during parameter expansion?