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
This commit is contained in:
Dave Thomas 2014-05-16 13:16:06 -07:00
parent 5b16eb0c33
commit 1a70916bca

View File

@ -43,7 +43,7 @@ do
echo "The package $i is not available and will not be installed" echo "The package $i is not available and will not be installed"
fi fi
done done
if [ -n "$WHITELIST" ]; then if [ ${#WHITELIST[@]} -eq 0 ]; then
if [ -f /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ]; then if [ -f /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ]; then
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
fi fi