Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Revert "archweb: use jq's -e flag to indicate not-found as failure"
Browse files Browse the repository at this point in the history
This reverts commit b233ace while
preserving bd3f96a.

jq, even with -e, does not exit non-zero when given an empty input. This
is apparently a known feature:

jqlang/jq#1497
jqlang/jq#1142

Thus, revert this oversimplification which leads to problems when curl
fails, or otherwise returns an empty response body.

Closes #29.
  • Loading branch information
falconindy committed Feb 12, 2019
1 parent fe50aec commit 4d4e4ab
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions archweb.inc.sh
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 4d4e4ab

Please sign in to comment.