From 799ccd27de66c598b908c3bed9ded7aa932348f5 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 21 Mar 2011 17:07:09 +0100 Subject: fall back to curl if fb-upload is unavailable Signed-off-by: Florian Pritz --- fb.in | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/fb.in b/fb.in index ce85695..b63ac28 100644 --- a/fb.in +++ b/fb.in @@ -63,9 +63,27 @@ do_upload() { return 1 fi fi - if ! $LIBDIR/fb-upload "$PASTEBIN/file/do_upload" "$file" > $TMPFILE; then - EXITCODE=1 - return 1 + + # fb-upload handles corner cases (comma in the filename) better + if [ -x "$LIBDIR/fb-upload" ]; then + if ! $LIBDIR/fb-upload "$PASTEBIN/file/do_upload" "$file" > $TMPFILE; then + EXITCODE=1 + return 1 + fi + else + CURLOPTS="-# -n -L -A $USERAGENT $EXTRA" + if [ `stat -c %s -- "$file"` -eq "0" ] || echo "$file" | grep -F -q ","; then + basefilename=`echo "$basefilename" | tr -d ,` + if ! curl $CURLOPTS -F "file=@-;filename=$basefilename" "$PASTEBIN/file/do_upload" < "$file" > $TMPFILE; then + EXITCODE=1 + return 1 + fi + else + if ! curl $CURLOPTS -F "file=@$file" "$PASTEBIN/file/do_upload" > $TMPFILE; then + EXITCODE=1 + return 1 + fi + fi fi sed '$d' $TMPFILE >&2 URL=`tail -1 $TMPFILE`"$EXTENSION" -- cgit v1.2.3-24-g4f1b