From: Mike Frysinger Date: Thu, 2 Jan 2014 20:33:22 +0000 (-0500) Subject: gentoo: att: support multiple files X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=294704a27661b5c136e959c3abbb380a5fc12362;p=home.git gentoo: att: support multiple files --- diff --git a/.profile.d/gentoo.sh b/.profile.d/gentoo.sh index 1f29037..24e10ad 100644 --- a/.profile.d/gentoo.sh +++ b/.profile.d/gentoo.sh @@ -114,16 +114,21 @@ ec() { } att() { - declare url=$1 tmp=$(mktemp) filename || return 1 - [[ $url == */* ]] || url="http://bugs.gentoo.org/attachment.cgi?id=$url" - eval $(wget -S -O"$tmp" "$url" 2>&1 | tee /dev/tty | \ - grep 'Content-disposition:' | sed 's/.* //') && \ - mv "$tmp" "$filename" && \ - chmod $(printf "%03o" "$((0666 & ~$(umask)))") "$filename" && \ - ls -l "$filename" && \ - return 0 - rm -f "$tmp" - return 1 + while [[ $# -gt 0 ]] ; do + declare url=$1 tmp=$(mktemp) filename || return 1 + [[ ${url} == */* ]] || url="http://bugs.gentoo.org/attachment.cgi?id=${url}" + printf '%s -> ' "${url}" + if eval $(wget -S -O"${tmp}" "${url}" 2>&1 | + grep 'Content-disposition:' | sed 's/.* //') && \ + mv "${tmp}" "${filename}" && \ + chmod $(printf "%03o" "$((0666 & ~$(umask)))") "${filename}" ; then + du -b "${filename}" + else + echo "FAIL" + rm -f "${tmp}" + fi + shift + done } arch_emails() { local ret