summaryrefslogtreecommitdiff
path: root/cron-jobs/check_archlinux/parse_pkgbuilds.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-06-18 12:07:09 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-04-16 13:49:57 -0400
commit7850874b1ef1b18de585be108e3be899d95a3a2a (patch)
tree173896aa05b68545672124dbe28b098fec98ee0a /cron-jobs/check_archlinux/parse_pkgbuilds.sh
parent282bf65c81e278b9237b4c202d325642bc0aa1a3 (diff)
Fix quoting around variables, especially arrays.
Other than pure quoting, this involved: - swapping */@ for array access in a few places - fiddling with printf in a pipeline - replacing `$(echo ${array[@]})` with `${array[*]}` - replacing `echo $(...)` with `...` When searching for these things, I used the command: grep -Prn --exclude-dir=.git '(?<!["=]|\[\[ |\[\[ -[zn] )\$(?!{?#|\(|\? )' and ignored a bunch of false positives.
Diffstat (limited to 'cron-jobs/check_archlinux/parse_pkgbuilds.sh')
-rwxr-xr-xcron-jobs/check_archlinux/parse_pkgbuilds.sh52
1 files changed, 26 insertions, 26 deletions
diff --git a/cron-jobs/check_archlinux/parse_pkgbuilds.sh b/cron-jobs/check_archlinux/parse_pkgbuilds.sh
index 3f92169..38af179 100755
--- a/cron-jobs/check_archlinux/parse_pkgbuilds.sh
+++ b/cron-jobs/check_archlinux/parse_pkgbuilds.sh
@@ -6,23 +6,23 @@
exit() { return; }
splitpkg_overrides=('depends' 'optdepends' 'provides' 'conflicts')
-variables=('pkgname' 'pkgbase' 'epoch' 'pkgver' 'pkgrel' 'makedepends' 'arch' ${splitpkg_overrides[@]})
+variables=('pkgname' 'pkgbase' 'epoch' 'pkgver' 'pkgrel' 'makedepends' 'arch' "${splitpkg_overrides[@]}")
readonly -a variables splitpkg_overrides
backup_package_variables() {
- for var in ${splitpkg_overrides[@]}; do
+ for var in "${splitpkg_overrides[@]}"; do
indirect="${var}_backup"
- eval "${indirect}=(\${$var[@]})"
+ eval "${indirect}=(\"\${$var[@]}\")"
done
}
restore_package_variables() {
- for var in ${splitpkg_overrides[@]}; do
+ for var in "${splitpkg_overrides[@]}"; do
indirect="${var}_backup"
if [ -n "${!indirect}" ]; then
- eval "${var}=(\${$indirect[@]})"
+ eval "${var}=(\"\${$indirect[@]}\")"
else
- unset ${var}
+ unset "${var}"
fi
done
}
@@ -42,31 +42,31 @@ print_info() {
if [ -n "$arch" ]; then
echo "%ARCH%"
- for i in ${arch[@]}; do echo $i; done
+ for i in "${arch[@]}"; do echo "$i"; done
echo ""
fi
if [ -n "$depends" ]; then
echo "%DEPENDS%"
- for i in ${depends[@]}; do
- echo $i
+ for i in "${depends[@]}"; do
+ echo "$i"
done
echo ""
fi
if [ -n "$makedepends" ]; then
echo "%MAKEDEPENDS%"
- for i in ${makedepends[@]}; do
- echo $i
+ for i in "${makedepends[@]}"; do
+ echo "$i"
done
echo ""
fi
if [ -n "$conflicts" ]; then
echo "%CONFLICTS%"
- for i in ${conflicts[@]}; do echo $i; done
+ for i in "${conflicts[@]}"; do echo "$i"; done
echo ""
fi
if [ -n "$provides" ]; then
echo "%PROVIDES%"
- for i in ${provides[@]}; do echo $i; done
+ for i in "${provides[@]}"; do echo "$i"; done
echo ""
fi
}
@@ -75,10 +75,10 @@ source_pkgbuild() {
ret=0
dir=$1
pkgbuild=$dir/PKGBUILD
- for var in ${variables[@]}; do
- unset ${var}
+ for var in "${variables[@]}"; do
+ unset "${var}"
done
- source $pkgbuild &>/dev/null || ret=$?
+ source "$pkgbuild" &>/dev/null || ret=$?
# ensure $pkgname and $pkgver variables were found
if [ $ret -ne 0 -o -z "$pkgname" -o -z "$pkgver" ]; then
@@ -88,8 +88,8 @@ source_pkgbuild() {
if [ "${#pkgname[@]}" -gt "1" ]; then
pkgbase=${pkgbase:-${pkgname[0]}}
- for pkg in ${pkgname[@]}; do
- if [ "$(type -t package_${pkg})" != "function" ]; then
+ for pkg in "${pkgname[@]}"; do
+ if [ "$(type -t "package_${pkg}")" != "function" ]; then
echo -e "%INVALID%\n$pkgbuild\n"
return 1
else
@@ -98,13 +98,13 @@ source_pkgbuild() {
while IFS= read -r line; do
var=${line%%=*}
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
- for realvar in ${variables[@]}; do
+ for realvar in "${variables[@]}"; do
if [ "$var" == "$realvar" ]; then
eval $line
break
fi
done
- done < <(type package_${pkg})
+ done < <(type "package_${pkg}")
print_info
restore_package_variables
fi
@@ -124,14 +124,14 @@ find_pkgbuilds() {
return
fi
- if [ -f $1/PKGBUILD ]; then
- source_pkgbuild $1
+ if [ -f "$1/PKGBUILD" ]; then
+ source_pkgbuild "$1"
return
fi
empty=1
- for dir in $1/*; do
- if [ -d $dir ]; then
- find_pkgbuilds $dir
+ for dir in "$1"/*; do
+ if [ -d "$dir" ]; then
+ find_pkgbuilds "$dir"
unset empty
fi
done
@@ -147,7 +147,7 @@ fi
CARCH=$1
shift
for dir in "$@"; do
- find_pkgbuilds $dir
+ find_pkgbuilds "$dir"
done
exit 0