#!/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