From c08fc746070859ef01e69bd346782cba0c01a0a7 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 2 Oct 2016 22:46:51 +1100 Subject: [PATCH] Add error handling --- config/config | 2 +- neofetch | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/config/config b/config/config index 78af95fe..5f37472d 100644 --- a/config/config +++ b/config/config @@ -407,7 +407,7 @@ scrot_name="neofetch-$(date +%F-%I-%M-%S-${RANDOM}).png" # Image upload host # Where to upload the image. # Possible values: teknik, -image_host="teknik" +image_host="imgur" # Imgur api key # This is an api key for neofetch, you can sign up for your own diff --git a/neofetch b/neofetch index 95b7fa24..205caeaa 100755 --- a/neofetch +++ b/neofetch @@ -2315,11 +2315,15 @@ scrot_upload() { "imgur") image_url="$(curl -sH "Authorization: Client-ID $imgur_client_id" -F "image=@${image_file}" "https://api.imgur.com/3/upload")" image_url="$(awk -F 'id:|,' '{printf $2}' <<< "${image_url//\"}")" - image_url="https://i.imgur.com/${image_url}.png" + [ "$image_url" ] && image_url="https://i.imgur.com/${image_url}.png" ;; esac - [ "$image_url" ] && printf "%s\n" "$image_url" + if [ "$image_url" ]; then + printf "%s\n" "$image_url" + else + printf "%s\n" "[!] Image failed to upload" + fi } # }}}