diff options
author | Bo Ørsted Andresen <bo.andresen@zlin.dk> | 2007-03-20 04:03:45 +0000 |
---|---|---|
committer | Bo Ørsted Andresen <bo.andresen@zlin.dk> | 2007-03-20 04:03:45 +0000 |
commit | 3f868aef56d7224491c974ec5776f100fc14110b (patch) | |
tree | c39e9f0cb6320c5062de105ae9e71a1e2f524ecf | |
parent | 781a98e63ba40b46998b5d4e2abbf695ea4a6203 (diff) | |
download | wgetpaste-3f868aef56d7224491c974ec5776f100fc14110b.tar.gz |
Put input for warn_size() and verify_url() in ${service}_WARNS arrays rather than hard coding it in the functions.
-rwxr-xr-x | wgetpaste | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -71,6 +71,9 @@ ca_EXPIRATIONS=(Never 5\ minutes 10\ minutes 15\ minutes 30\ minutes 45\ minutes 3\ months 4\ months 5\ months 6\ months 1\ year) osl_EXPIRATIONS=(Never 1\ day 1\ month) osl_EXPIRATION_VALUES=(f d m) +# warns +ca_WARNS=(1024000 1\ MB) +rafb_WARNS=(512000 512\ kB http://rafb.net/p/toofast.html "You must wait at least 10 seconds between each paste! Try again in 10 seconds.") ### defaults @@ -212,14 +215,8 @@ warn_size() { echo "error output from wget if it fails. Alternatively use another pastebin service like e.g. sh." fi } - case "${SERVICE}" in - rafb ) - warn 512000 "512 kb" - ;; - ca ) - warn 1024000 "1 MB" - ;; - esac + local LIMIT=("$(eval "echo \"\${${SERVICE}_WARNS[0]}\"") ""$(eval "echo \"\${${SERVICE}_WARNS[1]}\"")") + [[ "${LIMIT}" != " " ]] && warn ${LIMIT[0]} ${LIMIT[1]} } post_data() { @@ -260,8 +257,8 @@ get_url() { # verify that the pastebin service didn't return a known error url or print a helpful error message verify_url() { - [[ "${SERVICE}" == "rafb" ]] && [[ "${URL}" == "http://rafb.net/p/toofast.html" ]] && \ - die "You must wait at least 10 seconds between each paste! Try again in 10 seconds." + local KNOWN="$(eval "echo \"\${${SERVICE}_WARNS[2]}\"")" + [[ "${URL}" == "${KNOWN}" ]] && die "$(eval "echo \"\${${SERVICE}_WARNS[3]}\"")" } # if possible convert URL to raw |