summaryrefslogtreecommitdiffstats
path: root/fb.in
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-09-02 16:02:39 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-09-02 16:02:39 +0200
commit4054b066ab69e403c3933ca28d32dd9bf91723f8 (patch)
treeecf62b20f2a67dbf04b9fdd4cb5f65159c17e048 /fb.in
parentde5740a8a3457aad8a4049dddc26a173927edf9a (diff)
Use bash arrays to allow spaces in apikey file path
This also fixes a bug in the shell uploader which used single quotes around the argument to --data-urlencode which sadly doesn't work at all. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'fb.in')
-rw-r--r--fb.in36
1 files changed, 18 insertions, 18 deletions
diff --git a/fb.in b/fb.in
index ccc6236..f3e36c2 100644
--- a/fb.in
+++ b/fb.in
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#----------------------------------------------------
# Author: Florian "Bluewind" Pritz <flo@xssn.at>
# Contributor: Moritz Wilhelmy
@@ -52,7 +52,7 @@ clipboard=""
exitcode=0
debug=
useragent="fb-client/shell-$version"
-default_curlopts="-# -L -A $useragent --speed-time 30 --speed-limit 1 --connect-timeout 10"
+default_curlopts=(-# -L -A "$useragent" --speed-time 30 --speed-limit 1 --connect-timeout 10)
base64_encode() {
if type base64 2>&1 >/dev/null; then
@@ -73,40 +73,40 @@ request_helper() {
# if available use the external helper, else fall back to calling curl
if [ -x "$libdir/fb-helper" ]; then
- helperopts=""
+ helperopts=()
if [ "$debug" ]; then
- helperopts="$helperopts -D"
+ helperopts+=(-D)
fi
if [ -e "$apikey_file" ]; then
- helperopts="$helperopts -a $apikey_file"
+ helperopts+=(-a $apikey_file)
fi
if [ "$mode" = "d" ]; then
- $libdir/fb-helper $helperopts -u "$url"
+ $libdir/fb-helper "${helperopts[@]}" -u "$url"
fi
if [ "$mode" = "u" ]; then
- $libdir/fb-helper $helperopts -u "$url" -f "$file"
+ $libdir/fb-helper "${helperopts[@]}" -u "$url" -f "$file"
fi
else
- curlopts="$default_curlopts"
+ curlopts=(${default_curlopts[@]})
require_executable curl
if [ -e "$apikey_file" ]; then
- curlopts="$curlopts --data-urlencode 'apikey@$apikey_file'"
+ curlopts+=("--data-urlencode" "apikey@${apikey_file}")
else
- curlopts="$curlopts -n"
+ curlopts+=("-n")
fi
if [ "$debug" ]; then
- curlopts="$curlopts -v"
+ curlopts+=("-v")
fi
if [ "$mode" = "d" ]; then
- curlopts="$curlopts -s"
+ curlopts+=("-s")
fi
if [ "$mode" = "u" ]; then
@@ -117,12 +117,12 @@ request_helper() {
return 1
fi
base64fn="`base64_encode "$basefilename"`"
- curl $curlopts -F "file=@-" -F "filename=$base64fn" "$url" < "$file" -o /dev/stdout
+ curl "${curlopts[@]}" -F "file=@-" -F "filename=$base64fn" "$url" < "$file" -o /dev/stdout
else
- curl $curlopts -F "file=@$file" "$url" -o /dev/stdout
+ curl "${curlopts[@]}" -F "file=@$file" "$url" -o /dev/stdout
fi
else
- curl $curlopts "$url"
+ curl "${curlopts[@]}" "$url"
fi
fi
}
@@ -249,12 +249,12 @@ create_apikey() {
stty echo
printf "\n"
- curlopts="$default_curlopts"
+ curlopts=(${default_curlopts[@]})
if [ "$debug" ]; then
- curlopts="$curlopts -v"
+ curlopts+=(-v)
fi
- curl $curlopts -w "%{http_code}\n" -s -F "username=<$tmpdir/username" -F "password=<$tmpdir/password" -F "comment=fb-client $USER@$HOST" "$pastebin/user/create_apikey" > "$tmpdir/api-result"
+ curl "${curlopts[@]}" -w "%{http_code}\n" -s -F "username=<$tmpdir/username" -F "password=<$tmpdir/password" -F "comment=fb-client $USER@$HOST" "$pastebin/user/create_apikey" > "$tmpdir/api-result"
rm "$tmpdir/username" "$tmpdir/password"