summaryrefslogtreecommitdiffstats
path: root/fb
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-07-26 18:08:55 +0200
committerFlorian Pritz <bluewind@xssn.at>2010-07-26 18:08:55 +0200
commit304d9bf5f631a4402d5eaf1da050d36b8a62c91f (patch)
tree9947fe229603b6e03f6492eb845fa8c8848c782f /fb
parent3e032c563ff857c49e141ef88694e2423cfa5ee3 (diff)
downloadbin-304d9bf5f631a4402d5eaf1da050d36b8a62c91f.tar.gz
bin-304d9bf5f631a4402d5eaf1da050d36b8a62c91f.tar.xz
fb: fix handling of spaces, depend on getopts
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'fb')
-rwxr-xr-xfb24
1 files changed, 9 insertions, 15 deletions
diff --git a/fb b/fb
index 1ff49ae..d77cd81 100755
--- a/fb
+++ b/fb
@@ -64,23 +64,17 @@ usage: [cat |] `basename "$0"` [switches] [file(s)|ID(s)]
!
}
-if ! set -- `getopt ":e:gdh" "$@"`; then
- help
- exit 1
-fi
-
-for OPTION; do
+while getopts "e:g:dh" OPTION; do
case $OPTION in
- -e) shift; EXTENSION="$1";;
- -g) GET=1;;
- -d) DELETE=1;;
- -h) help; exit 0;;
- --) break;;
+ e) EXTENSION="$OPTARG";;
+ g) GET=1;;
+ d) DELETE=1;;
+ h|\?) help; exit 0;;
esac
- shift
done
-shift
+shift `expr $OPTIND - 1`
+
TMPDIR="`mktemp -d "/tmp/fb.XXXXXX"`"
trap "rm -rf '${TMPDIR}'" EXIT TERM
@@ -89,7 +83,7 @@ if [ $# -eq 0 ]; then
read_stdin "$TMPDIR/stdin"
do_upload "$TMPDIR/stdin"
else
- for i; do
+ for i in "$@"; do
if [ "$DELETE" ]; then
curl -n -L -A $USERAGENT "$PASTEBIN/file/delete/$i"
elif [ "$GET" ]; then
@@ -101,7 +95,7 @@ else
do_upload "$f" && rm -f "$f"
done
else
- do_upload $i
+ do_upload "$i"
fi
done
fi