commit 2cb57525efcf421231ac44ddad84a946e5b0551f parent 95421d97c45f8e099742327560184d78b87d31f9 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Sat, 6 Jun 2020 21:31:37 +0200 Show hurl/curl error message on failure Diffstat:
M | .local/bin/plumb | | | 10 | ++++++++-- |
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/.local/bin/plumb b/.local/bin/plumb @@ -57,13 +57,19 @@ fetch() { if regeximatch "$1" "\.onion"; then prefix=torsocks fi + err="" if command -v hurl >/dev/null 2>&1; then - $prefix hurl "$1" > "$_o" + $prefix hurl "$1" > "$_o" 2> /tmp/plumb_err elif command -v curl >/dev/null 2>&1; then - $prefix curl -sL "$1" > "$_o" + $prefix curl -sL "$1" > "$_o" 2> /tmp/plumb_err else die 'could not find hurl or curl' fi + if [ $? -ne 0 ]; then + msg="could not fetch $1\n\n$(cat /tmp/plumb_err)" + printf '%s\n' "$msg" >&2 + notify-send "${0##*/}" "$msg" + fi printf '%s' "$_o" }