makepkg: use less local variables in check_sanity

Instead of declaring a new local variable for each loop in the
check_sanity() function, just reuse $i.

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2010-08-05 21:35:54 +10:00 committed by Dan McGee
parent f04530eb61
commit 08e1d4764c

View file

@ -1186,9 +1186,8 @@ check_sanity() {
fi fi
done done
local name for i in "${pkgname[@]}"; do
for name in "${pkgname[@]}"; do if [[ ${i:0:1} = "-" ]]; then
if [[ ${name:0:1} = "-" ]]; then
error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname"
return 1 return 1
fi fi
@ -1218,31 +1217,27 @@ check_sanity() {
fi fi
fi fi
local provide for i in ${provides[@]}; do
for provide in ${provides[@]}; do if [[ $i != ${i//</} || $i != ${i//>/} ]]; then
if [[ $provide != ${provide//</} || $provide != ${provide//>/} ]]; then
error "$(gettext "Provides array cannot contain comparison (< or >) operators.")" error "$(gettext "Provides array cannot contain comparison (< or >) operators.")"
return 1 return 1
fi fi
done done
local file for i in "${backup[@]}"; do
for file in "${backup[@]}"; do if [[ ${i:0:1} = "/" ]]; then
if [[ ${file:0:1} = "/" ]]; then error "$(gettext "Backup entry should not contain leading slash : %s")" "$i"
error "$(gettext "Backup entry should not contain leading slash : %s")" "$file"
return 1 return 1
fi fi
done done
local optdepend for i in "${optdepends[@]}"; do
for optdepend in "${optdepends[@]}"; do local pkg=${i%%:*}
local pkg=${optdepend%%:*}
if [[ ! $pkg =~ ^[[:alnum:]\>\<\=\.\+\_\-]*$ ]]; then if [[ ! $pkg =~ ^[[:alnum:]\>\<\=\.\+\_\-]*$ ]]; then
error "$(gettext "Invalid syntax for optdepend : '%s'")" "$optdepend" error "$(gettext "Invalid syntax for optdepend : '%s'")" "$i"
fi fi
done done
local i
for i in 'changelog' 'install'; do for i in 'changelog' 'install'; do
local filelist=$(sed -n "s/^[[:space:]]*$i=//p" "$BUILDFILE") local filelist=$(sed -n "s/^[[:space:]]*$i=//p" "$BUILDFILE")
local file local file
@ -1257,17 +1252,17 @@ check_sanity() {
done done
local valid_options=1 local valid_options=1
local opt known kopt local known kopt
for opt in ${options[@]}; do for i in ${options[@]}; do
known=0 known=0
# check if option matches a known option or its inverse # check if option matches a known option or its inverse
for kopt in ${packaging_options[@]} ${other_options[@]}; do for kopt in ${packaging_options[@]} ${other_options[@]}; do
if [[ ${opt} = ${kopt} || ${opt} = "!${kopt}" ]]; then if [[ ${i} = ${kopt} || ${i} = "!${kopt}" ]]; then
known=1 known=1
fi fi
done done
if (( ! known )); then if (( ! known )); then
error "$(gettext "options array contains unknown option '%s'")" "$opt" error "$(gettext "options array contains unknown option '%s'")" "$i"
valid_options=0 valid_options=0
fi fi
done done
@ -1275,19 +1270,18 @@ check_sanity() {
return 1 return 1
fi fi
local pkg
if (( ${#pkgname[@]} > 1 )); then if (( ${#pkgname[@]} > 1 )); then
for pkg in ${pkgname[@]}; do for i in ${pkgname[@]}; do
if ! declare -f package_${pkg} >/dev/null; then if ! declare -f package_${i} >/dev/null; then
error "$(gettext "missing package function for split package '%s'")" "$pkg" error "$(gettext "missing package function for split package '%s'")" "$i"
return 1 return 1
fi fi
done done
fi fi
for pkg in ${PKGLIST[@]}; do for i in ${PKGLIST[@]}; do
if ! in_array $pkg ${pkgname[@]}; then if ! in_array $i ${pkgname[@]}; then
error "$(gettext "requested package %s is not provided in %s")" "$pkg" "$BUILDFILE" error "$(gettext "requested package %s is not provided in %s")" "$i" "$BUILDFILE"
return 1 return 1
fi fi
done done