summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBo Ørsted Andresen <bo.andresen@zlin.dk>2007-02-28 12:04:28 +0000
committerBo Ørsted Andresen <bo.andresen@zlin.dk>2007-02-28 12:04:28 +0000
commit150212c565b9f8e258cd322510bd6f36281a637a (patch)
tree999b8d724874b5a9a79ed1e701ba290846aa743d
parent1c0ce64132ca39e74fb9ce5344bf04011db12fc8 (diff)
downloadwgetpaste-150212c565b9f8e258cd322510bd6f36281a637a.tar.gz
Generalize a bit by detecting the toofast.html from rafb from verify_url().
-rwxr-xr-xwgetpaste23
1 files changed, 19 insertions, 4 deletions
diff --git a/wgetpaste b/wgetpaste
index 16d16d5..f307afd 100755
--- a/wgetpaste
+++ b/wgetpaste
@@ -131,6 +131,19 @@ post_data() {
esac
}
+
+# verify that the pastebin service didn't return a known error url such as toofast.html from rafb
+verify_url() {
+ case "${SERVICE}" in
+ rafb )
+ if [[ "${URL}" == "http://rafb.net/p/toofast.html" ]]; then
+ echo "You must wait at least 10 seconds between each paste! Try again in 10 seconds." 1>&2
+ exit 1
+ fi
+ ;;
+ esac
+}
+
### read cli options
# if you know a better option (like getopts) which provides the same features
@@ -280,10 +293,12 @@ fi
# get the url
URL="$(echo "${OUTPUT}" | sed -n 's|^.*Location:\ \(http://[^\ ]\+\).*$|\1|p')"
-if [[ "${URL}" == "http://rafb.net/p/toofast.html" ]]; then
- echo "You must wait at least 10 seconds between each paste! Try again in 10 seconds."
- exit 1
-elif [[ -z "${URL}" ]]; then
+# verify that the pastebin service didn't return a known error url such as toofast.html from rafb
+# uses ${SERVICE} and ${URL}.
+verify_url
+
+# handle the case when there was no location returned
+if [[ -z "${URL}" ]]; then
if [[ ${DEBUG} ]] || [[ ${VERBOSE} ]]; then
echo "Apparently nothing was received. Perhaps the connection failed." 1>&2
echo "${OUTPUT}" 1>&2