fix(generators): call PKG_INSTALL without '$' under 'set -u'
In bash with 'set -u', an undefined variable triggers an unbound-variable
error. Functions don't satisfy '$FUNCNAME' expansion under set -u, so
the previous fix that kept '$PKG_INSTALL pkg...' as the call syntax
broke every call site:
docker.sh: line 53: PKG_INSTALL: unbound variable
Fix: drop the leading '$' in all 47 call sites across 6 generator
files. 'PKG_INSTALL pkg...' is a normal command/function lookup and
behaves identically under set -u or not.
Verified: web UI served docker.sh now has 'PKG_INSTALL' (no $);
'bash -n' passes; smoke run with stubbed PATH hits real line-53 call
site, mock apt-get receives correct args, exit 0, no unbound variable.
Sampled 6 other generators also syntax-OK with $PKG_INSTALL count 0.
This commit is contained in:
@@ -150,17 +150,17 @@ class Grafana(Generator):
|
||||
out.append('log "Installing Grafana..."')
|
||||
out.append('case "$PKG" in\n'
|
||||
' apt-get)\n'
|
||||
' $PKG_INSTALL -y software-properties-common\n'
|
||||
' PKG_INSTALL -y software-properties-common\n'
|
||||
' mkdir -p /etc/apt/keyrings\n'
|
||||
' wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | tee /etc/apt/keyrings/grafana.gpg > /dev/null\n'
|
||||
' echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" > /etc/apt/sources.list.d/grafana.list\n'
|
||||
' apt-get update\n'
|
||||
' $PKG_INSTALL grafana\n'
|
||||
' PKG_INSTALL grafana\n'
|
||||
' ;;\n'
|
||||
' yum|dnf)\n'
|
||||
' cat > /etc/yum.repos.d/grafana.repo <<REPO_EOF\n'
|
||||
'[grafana]\nname=grafana\nbaseurl=https://rpm.grafana.com\nrepo=gpgkey\nenabled=1\ngpgcheck=1\ngpgkey=https://rpm.grafana.com/gpg.key\nREPO_EOF\n'
|
||||
' $PKG_INSTALL grafana\n'
|
||||
' PKG_INSTALL grafana\n'
|
||||
' ;;\n'
|
||||
'esac')
|
||||
out.append('systemctl enable --now grafana-server')
|
||||
|
||||
Reference in New Issue
Block a user