summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoritz Wilhelmy <moritz+git@wzff.de>2012-01-21 21:38:09 +0100
committerMoritz Wilhelmy <moritz+git@wzff.de>2012-01-21 21:43:50 +0100
commit16e05431a3eb9c5546e2a031956178ce82db1539 (patch)
tree6b7ae650a2f868414b137136f2713e5405561768
parent33544e122aa734337f5ca3a7a5ad17f8f93958a8 (diff)
Cherry-pick the stat(1) fix from the master branch
-rw-r--r--fb.in13
1 files changed, 10 insertions, 3 deletions
diff --git a/fb.in b/fb.in
index 7d9cf8b..1f62ea4 100644
--- a/fb.in
+++ b/fb.in
@@ -26,6 +26,13 @@ USERAGENT="fb-client/$VERSION"
CLIPBOARD=""
EXITCODE=0
+# the calling conventions for stat(1) are highly system dependent
+STAT='stat -c %s' # GNU stat(1) is the default since most people have it
+case "`uname -s`" in
+ *BSD) STAT='stat -f %z';;
+ Minix) STAT='stat -size';;
+esac
+
do_upload() {
local EXTRA=""
file="$1"
@@ -57,16 +64,16 @@ do_upload() {
EXTRA="-F extension=$EXTENSION"
fi
TMPFILE=`mktemp "$TMPDIR/data.XXXXXX"`
- if [ `stat -c %s -- "$file"` -gt "$WARNSIZE" ]; then
+ if [ `$STAT -- "$file"` -gt "$WARNSIZE" ]; then
WARNSIZE=`curl -s "$PASTEBIN/file/get_max_size"`
- if [ `stat -c %s -- "$file"` -gt "$WARNSIZE" ]; then
+ if [ `$STAT -- "$file"` -gt "$WARNSIZE" ]; then
echo "Warning: Your upload is too big and would be rejected. Maximum size is: $WARNSIZE bytes. Skipping..." >&2
EXITCODE=1
return 1
fi
fi
CURLOPTS="-# -n -L -A $USERAGENT $EXTRA"
- if [ `stat -c %s -- "$file"` -eq "0" ] || echo "$file" | grep -F -q ","; then
+ if [ `$STAT -- "$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