]> git.wh0rd.org Git - home.git/commitdiff
gentoo: att: support multiple files
authorMike Frysinger <vapier@gentoo.org>
Thu, 2 Jan 2014 20:33:22 +0000 (15:33 -0500)
committerMike Frysinger <vapier@gentoo.org>
Thu, 2 Jan 2014 20:33:22 +0000 (15:33 -0500)
.profile.d/gentoo.sh

index 1f29037ec860d9c5ac49488497b56c0293ed8982..24e10ad795235ad61a3189512924207bbe8da284 100644 (file)
@@ -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