summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2018-02-12 17:21:39 -0500
committerPierre Schmitz <mail@pierre-schmitz.com>2018-02-15 16:41:37 +0100
commiteec8e35eba84658bdd03230c83f449d2bb437b10 (patch)
tree99a543ed6ee3aa874aa47234ab1f7cdc61e1729f
parent1cad51c5af4b0aa1e1196d737edaa00938af937f (diff)
Use return codes properly when checking for failed commands.
Rather than doing a test(1) on the numerical value of the return code, use the `if !` and `||` operators during control flow.
-rw-r--r--db-functions36
-rwxr-xr-xdb-update3
2 files changed, 13 insertions, 26 deletions
diff --git a/db-functions b/db-functions
index 38b3c2f..f0bf43f 100644
--- a/db-functions
+++ b/db-functions
@@ -292,12 +292,9 @@ getpkgfiles() {
check_pkgfile() {
local pkgfile=$1
- local pkgname="$(getpkgname ${pkgfile})"
- [ $? -ge 1 ] && return 1
- local pkgver="$(getpkgver ${pkgfile})"
- [ $? -ge 1 ] && return 1
- local pkgarch="$(getpkgarch ${pkgfile})"
- [ $? -ge 1 ] && return 1
+ local pkgname="$(getpkgname ${pkgfile})" || return 1
+ local pkgver="$(getpkgver ${pkgfile})" || return 1
+ local pkgarch="$(getpkgarch ${pkgfile})" || return 1
in_array "${pkgarch}" ${ARCHES[@]} 'any' || return 1
@@ -310,14 +307,10 @@ check_pkgfile() {
check_pkgsvn() {
local pkgfile="${1}"
- local _pkgbase="$(getpkgbase ${pkgfile})"
- [ $? -ge 1 ] && return 1
- local _pkgname="$(getpkgname ${pkgfile})"
- [ $? -ge 1 ] && return 1
- local _pkgver="$(getpkgver ${pkgfile})"
- [ $? -ge 1 ] && return 1
- local _pkgarch="$(getpkgarch ${pkgfile})"
- [ $? -ge 1 ] && return 1
+ local _pkgbase="$(getpkgbase ${pkgfile})" || return 1
+ local _pkgname="$(getpkgname ${pkgfile})" || return 1
+ local _pkgver="$(getpkgver ${pkgfile})" || return 1
+ local _pkgarch="$(getpkgarch ${pkgfile})" || return 1
local repo="${2}"
in_array "${repo}" ${PKGREPOS[@]} || return 1
@@ -325,8 +318,7 @@ check_pkgsvn() {
if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then
mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}"
arch_svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \
- "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null
- [ $? -ge 1 ] && return 1
+ "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null || return 1
fi
local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; get_full_version)"
@@ -360,8 +352,7 @@ check_splitpkgs() {
if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then
mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}"
arch_svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \
- "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null
- [ $? -ge 1 ] && return 1
+ "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null || return 1
fi
local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]}))
@@ -386,12 +377,9 @@ check_splitpkgs() {
check_pkgrepos() {
local pkgfile=$1
- local pkgname="$(getpkgname ${pkgfile})"
- [ $? -ge 1 ] && return 1
- local pkgver="$(getpkgver ${pkgfile})"
- [ $? -ge 1 ] && return 1
- local pkgarch="$(getpkgarch ${pkgfile})"
- [ $? -ge 1 ] && return 1
+ local pkgname="$(getpkgname ${pkgfile})" || return 1
+ local pkgver="$(getpkgver ${pkgfile})" || return 1
+ local pkgarch="$(getpkgarch ${pkgfile})" || return 1
[ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} ] && return 1
[ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT}.sig ] && return 1
diff --git a/db-update b/db-update
index 54e60cb..f473f45 100755
--- a/db-update
+++ b/db-update
@@ -9,8 +9,7 @@ if [ $# -ge 1 ]; then
fi
# Find repos with packages to release
-staging_repos=($(find "${STAGING}" -mindepth 1 -type f -name "*${PKGEXT}" -printf '%h\n' | sort -u))
-if [ $? -ge 1 ]; then
+if ! staging_repos=($(find "${STAGING}" -mindepth 1 -type f -name "*${PKGEXT}" -printf '%h\n' | sort -u)); then
die "Could not read ${STAGING}"
fi