timgurup: use stdin when no args provided - scripts - various script and utils
 (HTM) git clone git://z3bra.org/scripts
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit 3672216648b26444310c3c1bb5d4cd29aa9881a5
 (DIR) parent 185e52b8e623acceb313a43275416246ea67ee64
 (HTM) Author: z3bra <willy@mailoo.org>
       Date:   Sat,  6 Dec 2014 12:37:50 +0100
       
       imgurup: use stdin when no args provided
       
       Diffstat:
         M imgurup                             |      15 ++++-----------
       
       1 file changed, 4 insertions(+), 11 deletions(-)
       ---
 (DIR) diff --git a/imgurup b/imgurup
       t@@ -4,21 +4,14 @@
        # appends links and deletion links to the log
        # depends: curl
        
       -# check if all args exist as files
       -for F in "$@"; do
       -    if ! test -f "$F"; then
       -        echo usage: $(basename $0) image ... && exit 1
       -    fi
       -done
       +# use stdin if no file provided
       +test -z "$@" && FILES='-' || FILES="$@"
        
        LOG=$HOME/.imgurlog
        
        # from http://imgur.com/tools/imgurbash.sh
        APIKEY='b3625162d3418ac51a9ee805b1840452'
        
       -# use stdin if no file provided
       -test -z "$@" && FILES='-' || FILES="$@"
       -
        # upload all
        for IMG in "$FILES"; do
            RESP=$(curl -F "image=@$IMG" -F "key=$APIKEY" \
       t@@ -27,7 +20,7 @@ for IMG in "$FILES"; do
            URL=$(echo $RESP | sed 's|.*<original_image>\(.*\)</original_image>.*|\1|')
            DELETEURL=$(echo $RESP | sed 's|.*<delete_page>\(.*\)</delete_page>.*|\1|')
        
       -    echo "$URL" | tee $LOG
       -    echo "$DELETEURL" >> $LOG
       +    echo "$URL"         >  $LOG
       +    echo "$DELETEURL"   >> $LOG
            echo "$URL"
        done