From 5c546cc5b882f1e18ac419546e62ed138f532196 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 17 Apr 2022 06:58:31 +0200 Subject: [PATCH] puttmpninja: Return with error code if curl fails --- .config/zsh/functions/puttmpninja | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.config/zsh/functions/puttmpninja b/.config/zsh/functions/puttmpninja index af1a301..d9ed242 100755 --- a/.config/zsh/functions/puttmpninja +++ b/.config/zsh/functions/puttmpninja @@ -7,16 +7,17 @@ zmodload zsh/zutil local -a o_help=() zparseopts -D -K -- h=o_help if [[ ${#o_help} -ne 0 || ! -v 1 ]]; then - ret=$(( ${#o_help} ^ 1 )) + local ret=$(( ${#o_help} ^ 1 )) print -u $(( 1 + ${ret} )) -l "usage: ${0} [-h] …" \ "\e[3mFiles on tmp.ninja expire after 48 hours.\e[0m" return ${ret} fi for file in ${@}; do - print -n '\e[0;94m' + print -Pn '%F{12}' local url=$(curl --progress-bar --form "files[]=@${file}" \ 'https://tmp.ninja/upload.php?output=text') - print '\e[1;95m→\e[0m' "\e[0;97m${url}\e[0m" \ + [[ ${url} == "" ]] && return 1 + print -P '%B%F{13}→%f%b' "%F{15}${url}%f" \ "\e[3;90mexpires: $(date --date='now + 2 days')\e[0m" done