summaryrefslogtreecommitdiffstats
path: root/fb.in
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@server-speed.net>2011-06-03 22:54:47 +0200
committerFlorian Pritz <bluewind@server-speed.net>2011-06-03 22:54:47 +0200
commit6a7da5c15e79d70d3f866bd0d3467103eb6e84d1 (patch)
tree7234dde0a9b89c366ca430ed9b22146d51cd6ed0 /fb.in
parentea58b13dc686a9f22ce945347a95c4bd96d5dd0c (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.in28
1 files changed, 16 insertions, 12 deletions
diff --git a/fb.in b/fb.in
index b899d5d..40f4258 100644
--- a/fb.in
+++ b/fb.in
@@ -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