summaryrefslogtreecommitdiffstats
path: root/fb.in
diff options
context:
space:
mode:
Diffstat (limited to 'fb.in')
-rw-r--r--fb.in46
1 files changed, 34 insertions, 12 deletions
diff --git a/fb.in b/fb.in
index ead38ef..2d9df34 100644
--- a/fb.in
+++ b/fb.in
@@ -31,6 +31,28 @@ require_executable() {
fi
}
+is_url() {
+ if echo "$i" | grep -qE "^(f|ht)tp(s)?://.+"; then
+ return 0
+ fi
+ return 1
+}
+
+do_tar_upload() {
+ if [ "$COMPRESS" = "1" ]; then
+ file="$TMPDIR/upload.tar.gz"
+ tar -cf - -- "$@" | gzip -c > "$file" || return 1
+ elif [ "$COMPRESS" = "2" ]; then
+ file="$TMPDIR/upload.tar.xz"
+ tar -cf - -- "$@" | xz -c > "$file" || return 1
+ else
+ file="$TMPDIR/upload.tar"
+ tar -cf "$file" -- "$@" || return 1
+ fi
+ COMPRESS=0
+ do_upload "$file" || return 1
+}
+
do_upload() {
local EXTRA=""
file="$1"
@@ -177,22 +199,22 @@ elif [ $# -eq 0 ]; then
do_upload "$TMPDIR/stdin" || EXITCODE=1
else
if [ "$TAR" ]; then
- if [ "$COMPRESS" = "1" ]; then
- file="$TMPDIR/upload.tar.gz"
- tar -cf - -- "$@" | gzip -c > "$file"
- elif [ "$COMPRESS" = "2" ]; then
- file="$TMPDIR/upload.tar.xz"
- tar -cf - -- "$@" | xz -c > "$file"
+ HAVE_URL=
+ for i in "$@"; do
+ if is_url "$i"; then
+ HAVE_URL=1
+ fi
+ done
+ if [ "$HAVE_URL" ]; then
+ # TODO: support -t when passing URLs as arguments
+ echo "Error: -t is not yet supported when operating on a URL" >&2
+ exit 1
else
- file="$TMPDIR/upload.tar"
- tar -cf "$file" -- "$@"
+ do_tar_upload "$@" || EXITCODE=1
fi
- COMPRESS=0
- do_upload "$file" || EXITCODE=1
- break
else
for i in "$@"; do
- if echo "$i" | grep -qE "^(f|ht)tp(s)?://.+"; then
+ if is_url "$i"; then
cd $TMPDIR
if ! $LIBDIR/fb-helper d "$i" > "`basename "$i"`"; then
EXITCODE=1