From 50b67be7e409161f5c6f4847ca2beb23e81b51ae Mon Sep 17 00:00:00 2001 From: William Harrington Date: Fri, 26 Mar 2021 15:03:25 -0500 Subject: Create a script exporting separate functions and remove download function from downloads script. Reformat MD5 mismatch failed message. --- functions.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 functions.sh (limited to 'functions.sh') diff --git a/functions.sh b/functions.sh new file mode 100644 index 0000000..d2ff5be --- /dev/null +++ b/functions.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +download() +{ + tput civis + local url=$1 + echo -n " " + wget -nc -q --show-progress --progress=dot "$url" 2>&1 | grep --line-buffered "%" | \ + sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}' + local retval="${PIPESTATUS[0]}" + if [ "${retval}" -ne 0 ]; then + printf "%b" "${RED}FAILED! WGET EXIT (${retval})\n${RST}" + exit "${retval}" + fi + printf "%b" "\b\b\b\b\n" + tput cnorm +} + +export -f download -- cgit v1.2.3-54-g00ecf