diff options
author | Florian Pritz <bluewind@server-speed.net> | 2011-06-03 22:54:47 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@server-speed.net> | 2011-06-03 22:54:47 +0200 |
commit | 6a7da5c15e79d70d3f866bd0d3467103eb6e84d1 (patch) | |
tree | 7234dde0a9b89c366ca430ed9b22146d51cd6ed0 /fb.in | |
parent | ea58b13dc686a9f22ce945347a95c4bd96d5dd0c (diff) |
move -d and -g code
If these switches are present and there are no arguments the program
should exit and not try to upload stdin.
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
Diffstat (limited to 'fb.in')
-rw-r--r-- | fb.in | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -154,7 +154,21 @@ shift `expr $OPTIND - 1` TMPDIR="`mktemp -d "/tmp/fb.XXXXXX"`" trap "rm -rf '${TMPDIR}'" EXIT TERM -if [ $# -eq 0 ]; then +if [ "$DELETE" ] || [ "$GET" ]; then + [ $# -eq 0 ] && exit 1; + for i in "$@"; do + i=$(id_from_arg "$i") + if [ "$DELETE" ]; then + if ! curl -n -L -A $USERAGENT "$PASTEBIN/file/delete/$i"; then + EXITCODE=1 + fi + elif [ "$GET" ]; then + if ! curl -s -o - -A $USERAGENT "$PASTEBIN/$i"; then + EXITCODE=1 + fi + fi + done +elif [ $# -eq 0 ]; then read_stdin "$TMPDIR/stdin" do_upload "$TMPDIR/stdin" else @@ -165,17 +179,7 @@ else break else for i in "$@"; do - if [ "$DELETE" ]; then - i=$(id_from_arg "$i") - if ! curl -n -L -A $USERAGENT "$PASTEBIN/file/delete/$i"; then - EXITCODE=1 - fi - elif [ "$GET" ]; then - i=$(id_from_arg "$i") - if ! curl -s -o - -A $USERAGENT "$PASTEBIN/$i"; then - EXITCODE=1 - fi - elif echo "$i" | grep -qE "^(f|ht)tp(s)?://.+"; then + if echo "$i" | grep -qE "^(f|ht)tp(s)?://.+"; then cd $TMPDIR if ! curl -# -A $USERAGENT -O "$i"; then EXITCODE=1 |