From 1a70916bcaa969b92d45d416652c1f278949ea9e Mon Sep 17 00:00:00 2001 From: Dave Thomas Date: Fri, 16 May 2014 13:16:06 -0700 Subject: [PATCH] `set -u` doesn't permit bash arrays to test -n Although set -u allows empty WHITELIST=() list to be set, you can't test -n "$WHITELIST". Looks like the intention of the commit that caused this issue (Change-ID Iad2d490c86dceab148ea9ab08f457c49a5d5352e) is to set a policy to prevent future use of bugs due to unbound variables. Thanks StevenK for pairing with me and helping me hone my bash skills. Change-Id: I2349c990ba53b0aaecd5119812582c7c848f1e4e Closes-Bug: #1319987 --- elements/yum/bin/install-packages | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elements/yum/bin/install-packages b/elements/yum/bin/install-packages index 218dd5342..11ca09959 100755 --- a/elements/yum/bin/install-packages +++ b/elements/yum/bin/install-packages @@ -43,7 +43,7 @@ do echo "The package $i is not available and will not be installed" fi done -if [ -n "$WHITELIST" ]; then +if [ ${#WHITELIST[@]} -eq 0 ]; then if [ -f /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ]; then rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release fi