diff options
author | Florian Pritz <bluewind@xssn.at> | 2010-07-26 18:08:55 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xssn.at> | 2010-07-26 18:08:55 +0200 |
commit | 304d9bf5f631a4402d5eaf1da050d36b8a62c91f (patch) | |
tree | 9947fe229603b6e03f6492eb845fa8c8848c782f /fb | |
parent | 3e032c563ff857c49e141ef88694e2423cfa5ee3 (diff) | |
download | bin-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-x | fb | 24 |
1 files changed, 9 insertions, 15 deletions
@@ -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 |