Skip to content

Commit a35ad27

Browse files
author
armab
committed
Fix '!env_var: unbound variable' when checking for var isset with bash '-u' mode
1 parent a6e2501 commit a35ad27

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

scripts/includes/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function configure_proxy() {
1414
sudo test -e ${service_config} || sudo touch ${service_config}
1515
for env_var in http_proxy https_proxy no_proxy proxy_ca_bundle_path; do
1616
# delete line from file if specific proxy env var is unset
17-
if sudo test -z ${!env_var}; then
17+
if sudo test -z "${!env_var:-}"; then
1818
sudo sed -i "/^${env_var}=/d" ${service_config}
1919
# add proxy env var if it doesn't exist yet
2020
elif ! sudo grep -s -q ^"${env_var}=" ${service_config}; then

scripts/st2bootstrap-el6.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function configure_proxy() {
126126
sudo test -e ${service_config} || sudo touch ${service_config}
127127
for env_var in http_proxy https_proxy no_proxy proxy_ca_bundle_path; do
128128
# delete line from file if specific proxy env var is unset
129-
if sudo test -z ${!env_var}; then
129+
if sudo test -z "${!env_var:-}"; then
130130
sudo sed -i "/^${env_var}=/d" ${service_config}
131131
# add proxy env var if it doesn't exist yet
132132
elif ! sudo grep -s -q ^"${env_var}=" ${service_config}; then

scripts/st2bootstrap-el7.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function configure_proxy() {
126126
sudo test -e ${service_config} || sudo touch ${service_config}
127127
for env_var in http_proxy https_proxy no_proxy proxy_ca_bundle_path; do
128128
# delete line from file if specific proxy env var is unset
129-
if sudo test -z ${!env_var}; then
129+
if sudo test -z "${!env_var:-}"; then
130130
sudo sed -i "/^${env_var}=/d" ${service_config}
131131
# add proxy env var if it doesn't exist yet
132132
elif ! sudo grep -s -q ^"${env_var}=" ${service_config}; then

0 commit comments

Comments
 (0)