From 2f623dfb3a16abd7299774379b4c3642b0b1d9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lesimple?= Date: Mon, 27 Dec 2021 13:04:36 +0000 Subject: [PATCH] fix: install.inc: fail nicely on invalid JSON under set -e --- lib/shell/install.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/shell/install.inc b/lib/shell/install.inc index 4fc163b..3e83e4f 100644 --- a/lib/shell/install.inc +++ b/lib/shell/install.inc @@ -70,7 +70,7 @@ set_download_url() { if command -v jq >/dev/null; then # If we have jq, we can do it properly - urls="$(jq -r '.[0].assets|.[]|.browser_download_url' < "$payload")" + urls="$(jq -r '.[0].assets|.[]|.browser_download_url' < "$payload" || true)" elif perl -MJSON -e 1 2>/dev/null; then # If we don't, there's a good chance we have Perl with the JSON module, use it urls="$(perl -MJSON -e 'undef $/; $d=decode_json(<>); exit if ref $d ne "ARRAY"; foreach(@{ $d->[0]{assets} || [] }) { print $_->{browser_download_url}."\n" }' "$payload")"