libmakepkg/lint_pkgbuild: check for invalid variables even if they're empty
Checking the length of the variable to be non-zero before considering it an error is inconsistent; license=() and depends='' and `declare arch` should be considered just as wrong. In fact the current check detects depends='' as non-zero and returns an error, but happily considers the others to be perfectly okay. A more reliable check is to simply see if the name has been declared (whether it is set or not), and then enforce that it's been declared to the right type. As an added benefit, avoiding the creation of proxy-evaled variables to count the number of indexes results in simpler code. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
03d85763e0
commit
30e3e21e87
1 changed files with 6 additions and 10 deletions
|
@ -38,12 +38,11 @@ lint_variable() {
|
||||||
source)
|
source)
|
||||||
local string=(changelog epoch install pkgbase pkgdesc pkgrel pkgver url)
|
local string=(changelog epoch install pkgbase pkgdesc pkgrel pkgver url)
|
||||||
|
|
||||||
local i a v pkg keys out bad ret=0
|
local i a pkg out bad ret=0
|
||||||
|
|
||||||
# global variables
|
# global variables
|
||||||
for i in ${array[@]} ${arch_array[@]}; do
|
for i in ${array[@]} ${arch_array[@]}; do
|
||||||
eval "keys=(\"\${!$i[@]}\")"
|
if declare -p $i > /dev/null 2>&1; then
|
||||||
if (( ${#keys[*]} > 0 )); then
|
|
||||||
if ! is_array $i; then
|
if ! is_array $i; then
|
||||||
error "$(gettext "%s should be an array")" "$i"
|
error "$(gettext "%s should be an array")" "$i"
|
||||||
ret=1
|
ret=1
|
||||||
|
@ -55,11 +54,9 @@ lint_variable() {
|
||||||
[[ $a == "any" ]] && continue
|
[[ $a == "any" ]] && continue
|
||||||
|
|
||||||
for i in ${arch_array[@]}; do
|
for i in ${arch_array[@]}; do
|
||||||
v="${i}_${a}"
|
if declare -p "${i}_${a}" > /dev/null 2>&1; then
|
||||||
eval "keys=(\"\${!${v}[@]}\")"
|
if ! is_array ${i}_${a}; then
|
||||||
if (( ${#keys[*]} > 0 )); then
|
error "$(gettext "%s should be an array")" "${i}_${a}"
|
||||||
if ! is_array $v; then
|
|
||||||
error "$(gettext "%s_%s should be an array")" "$i" "$a"
|
|
||||||
ret=1
|
ret=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -67,8 +64,7 @@ lint_variable() {
|
||||||
done
|
done
|
||||||
|
|
||||||
for i in ${string[@]}; do
|
for i in ${string[@]}; do
|
||||||
eval "keys=(\"\${!$i[@]}\")"
|
if declare -p "$i" > /dev/null 2>&1; then
|
||||||
if (( ${#keys[*]} > 0 )); then
|
|
||||||
if is_array $i; then
|
if is_array $i; then
|
||||||
error "$(gettext "%s should not be an array")" "$i"
|
error "$(gettext "%s should not be an array")" "$i"
|
||||||
ret=1
|
ret=1
|
||||||
|
|
Loading…
Add table
Reference in a new issue