Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archweb.inc.sh
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2019-02-12 07:12:49 -0500
committerDave Reisner <dreisner@archlinux.org>2019-02-12 07:12:49 -0500
commit4d4e4ab07e2c6fb64a84727ca21dba6066598878 (patch)
tree4f6150767a8a76b817626e5b611a4b729ed6eaae /archweb.inc.sh
parentfe50aec47abf45175d01a620e81dc32f35f74fe0 (diff)
Revert "archweb: use jq's -e flag to indicate not-found as failure"
This reverts commit b233aceb92aed4fcdd6a918647c32c915d4fcc71 while preserving bd3f96a5171cf797bf8ba59601a1a767ed036a05. jq, even with -e, does not exit non-zero when given an empty input. This is apparently a known feature: https://github.com/stedolan/jq/issues/1497 https://github.com/stedolan/jq/issues/1142 Thus, revert this oversimplification which leads to problems when curl fails, or otherwise returns an empty response body. Closes #29.
Diffstat (limited to 'archweb.inc.sh')
-rw-r--r--archweb.inc.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/archweb.inc.sh b/archweb.inc.sh
index 6075c41..fd88c59 100644
--- a/archweb.inc.sh
+++ b/archweb.inc.sh
@@ -1,4 +1,9 @@
archweb_get_pkgbase() {
- curl -Gs "https://www.archlinux.org/packages/search/json/" --data-urlencode "q=$1" |
- jq -er --arg pkgname "$1" 'limit(1; .results[] | select(.pkgname == $pkgname).pkgbase)'
+ local pkgbase
+
+ pkgbase=$(curl -Gs 'https://www.archlinux.org/packages/search/json/' --data-urlencode "q=$1" |
+ jq -r --arg pkgname "$1" 'limit(1; .results[] | select(.pkgname == $pkgname).pkgbase)')
+ [[ $pkgbase ]] || return
+
+ printf '%s\n' "$pkgbase"
}