diff options
author | Bo Ørsted Andresen <bo.andresen@zlin.dk> | 2007-03-20 18:04:33 +0000 |
---|---|---|
committer | Bo Ørsted Andresen <bo.andresen@zlin.dk> | 2007-03-20 18:04:33 +0000 |
commit | 9bd011b50ee360636bc7048728105851817a7967 (patch) | |
tree | 8ce5700f6a32275857beef6cd8149d594fc7cc39 | |
parent | 36180db7268b4b561e88b51d550d2ccd12896a33 (diff) | |
download | wgetpaste-9bd011b50ee360636bc7048728105851817a7967.tar.gz |
Stop using fail() as it's broken and fixing it doesn't make sense anymore.
-rwxr-xr-x | wgetpaste | 28 |
1 files changed, 12 insertions, 16 deletions
@@ -21,14 +21,6 @@ die() { exit 1 } -# show that an option ${1} is not supported, run function that shows valid options ${3} and die -fail() { - [[ "${2}" == "service" ]] || local FOR=" for $(get_recipient)" - echo "\"$1\" is not a supported $2${FOR}."$'\n' 1>&2 - ${3} 1>&2 - exit 1 -} - # escape % (used for escaping), & (used as separator in POST data), + (used as space in POST data) and space escape() { echo "$*" | sed -e 's|%|%25|g' -e 's|&|%26|g' -e 's|+|%2b|g' -e 's| |+|g' @@ -144,14 +136,14 @@ usage() { ### show functions show() { - echo "${2}s supported by $(get_recipient) (case sensitive):" + echo "${1:0:1}${2:1}s supported by $(get_recipient) (case sensitive):" local nr extra nr="$(eval "echo \${#${ENGINE}_${1}[*]}")" - [[ "${3}" == expiration ]] && extra="$(eval "echo \${${SERVICE}[3]}")" - [[ ${nr} -eq 0 ]] && echo -e "\n${extra}\"${SERVICE}\" has no support for setting ${3}." 1>&2 + [[ "${2}" == expiration* ]] && extra="$(eval "echo \${${SERVICE}[3]}")" + [[ ${nr} -eq 0 ]] && echo -e "\n${extra}\"${SERVICE}\" has no support for setting ${2% *}." 1>&2 for ((i=0; i<${nr}; i++)); do eval "echo \" \${${ENGINE}_${1}[i]}\"" - done | ${4:-cat} + done | ${3:-cat} } show_services() { @@ -182,7 +174,9 @@ verify_service() { for s in "${SERVICES[@]}"; do [[ "$*" == "${s}" ]] && return 0 done - fail "$*" "service" "show_services" + echo -e "\"$*\" is not a supported service.\n" 1>&2 + show_services 1>&2 + exit 1 } verify() { @@ -201,7 +195,9 @@ verify() { else [[ "$(eval echo "\${${1}_SET}")" != 0 ]] && return 0 fi - fail "$(eval echo \${${1}})" "${2}" "$(eval echo show_${2// /_}s)" + echo -e "\"$(eval echo \${${1}})\" is not a supported ${2} for $(get_recipient).\n" 1>&2 + show ${1}S "${2}" 1>&2 + exit 1 } ### Posting helper functions @@ -424,10 +420,10 @@ NICK="${NICK:-$(escape "${DEFAULT_NICK}")}" CVT_TABS="No" # show languages if requested (needs to be done after the right service is selected) -[[ ${LIST_LANGUAGES} ]] && show LANGUAGES Language language sort && exit 0 +[[ ${LIST_LANGUAGES} ]] && show LANGUAGES language sort && exit 0 # show expiration options if requested (needs to be done after the right service is selected) -[[ ${LIST_EXPIRATION} ]] && show EXPIRATIONS "Expiration option" expiration && exit 0 +[[ ${LIST_EXPIRATION} ]] && show EXPIRATIONS "expiration option" && exit 0 # language needs to be verified before it is escaped but after service is selected [[ -n "$(eval "echo \${DEFAULT_LANGUAGE_${SERVICE}}")" ]] && LANGUAGE="${LANGUAGE:-$(eval "echo \${DEFAULT_LANGUAGE_${SERVICE}}")}" |