summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBo Ørsted Andresen <bo.andresen@zlin.dk>2007-03-06 12:53:36 +0000
committerBo Ørsted Andresen <bo.andresen@zlin.dk>2007-03-06 12:53:36 +0000
commit8b1feed4ab571370ebc24964c6fc2f7e8240af66 (patch)
treebe9650f85f91be93bddc8f10f4145f950b4692ad
parent0736402461f05adcf74b37044ecc05acb96f913e (diff)
downloadwgetpaste-8b1feed4ab571370ebc24964c6fc2f7e8240af66.tar.gz
Replace two huge if-else-if-else's with one case-esac and one small if-fi.
-rwxr-xr-xwgetpaste30
1 files changed, 17 insertions, 13 deletions
diff --git a/wgetpaste b/wgetpaste
index c0ee371..75b4ee7 100755
--- a/wgetpaste
+++ b/wgetpaste
@@ -541,24 +541,19 @@ if [[ -z "${DESCRIPTION}" ]]; then
fi
fi
-# handle the case where the input source (defaulting to /dev/stdin) isn't readable verbosely
-if [[ "${SOURCE}" != "command" ]] && [[ "${SOURCE}" != "info" ]] && [[ "${SOURCE}" != "xcut" ]] && [[ ! -r "${SOURCE}" ]]; then
- echo "The input source: \"${SOURCE}\" is not readable. Please specify a readable input source." 1>&2
- echo 1>&2
- show_usage 1>&2
- exit 1
-fi
-
# read input
-if [[ "${SOURCE}" == "command" ]]; then
+case "${SOURCE}" in
+ command )
PS1="$(get_ps1)"
for ((i=0 ; i<${#COMMANDS[*]}; i++)); do
INPUT="${INPUT}${PS1} ${COMMANDS[i]}"$'\n'"$(bash -c "${COMMANDS[i]}" 2>&1)"$'\n\n'
done
-elif [[ "${SOURCE}" == "info" ]]; then
+ ;;
+ info )
PS1="$(get_ps1)"
INPUT="${PS1} emerge --info"$'\n'"$(emerge --info --ignore-default-opts)"
-elif [[ "${SOURCE}" == "xcut" ]]; then
+ ;;
+ xcut )
if [[ "$(type -t get_from_clipboard)" == "function" ]]; then
INPUT="$(get_from_clipboard)"
else
@@ -574,9 +569,18 @@ elif [[ "${SOURCE}" == "xcut" ]]; then
echo "of xclip." 1>&2
exit 1
fi
-else
+ ;;
+ * )
+ # handle the case where the input source (defaulting to /dev/stdin) isn't readable verbosely
+ if [[ ! -r "${SOURCE}" ]]; then
+ echo "The input source: \"${SOURCE}\" is not readable. Please specify a readable input source." 1>&2
+ echo 1>&2
+ show_usage 1>&2
+ exit 1
+ fi
INPUT="$( < "${SOURCE}" )"
-fi
+ ;;
+esac
[[ -z "${INPUT}" ]] && die "No input read. Nothing to paste. Aborting."
# append emerge --info if needed