diff options
author | Bo Ørsted Andresen <bo.andresen@zlin.dk> | 2007-09-19 08:38:18 +0000 |
---|---|---|
committer | Bo Ørsted Andresen <bo.andresen@zlin.dk> | 2007-09-19 08:38:18 +0000 |
commit | da7ee39c65ebfb2f8e0cd583322d5f5aa90337cf (patch) | |
tree | 9aab9b768fd42d941173e5698a50d0e6f179f889 | |
parent | 59385608705d4cd1e0bbd673ea256391fae716e0 (diff) | |
download | wgetpaste-da7ee39c65ebfb2f8e0cd583322d5f5aa90337cf.tar.gz |
Die if sed, xclip or whoami fails. Make sure converttoraw() returns 1 if RAWURL ends up being empty. Die if any attempt to source a config file fails.
-rwxr-xr-x | wgetpaste | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -99,7 +99,7 @@ EOF # escape % (used for escaping), & (used as separator in POST data), + (used as space in POST data) and space escape() { - sed -e 's|%|%25|g' -e 's|&|%26|g' -e 's|+|%2b|g' -e 's| |+|g' <<< "$*" + sed -e 's|%|%25|g' -e 's|&|%26|g' -e 's|+|%2b|g' -e 's| |+|g' <<< "$*" || die "sed failed" } # if possible convert URL to raw @@ -108,8 +108,7 @@ converttoraw() { regex=REGEX_RAW_$ENGINE if [[ -n ${!regex} ]]; then RAWURL=$(sed -e "${!regex}" <<< "$URL") - set +x - return 0 + [[ -n $RAWURL ]] && return 0 fi echo "Raw download of pastes is not supported by $(getrecipient)." >&2 return 1 @@ -223,7 +222,7 @@ getfilenames() { x_cut() { if [[ -x $(type -P xclip) ]]; then - xclip -o + xclip -o || die "xclip failed." else noxclip cut "read from" fi @@ -324,7 +323,7 @@ showurl() { x_paste() { if [[ -x $(type -P xclip) ]]; then - xclip -loops 10 <<< "$*" + xclip -loops 10 <<< "$*" || die "xclip failed." else noxclip paste "write to" fi @@ -525,9 +524,11 @@ done ### defaults [[ $IGNORECONFIGS ]] || for f in {/etc/,~/.}wgetpaste{.d/*.bash,}; do - [[ -f $f ]] && . "$f" + if [[ -f $f ]]; then + . "$f" || die "Failed to source $f" + fi done -DEFAULT_NICK=${DEFAULT_NICK:-$(whoami)} +DEFAULT_NICK=${DEFAULT_NICK:-$(whoami)} || die "whoami failed" DEFAULT_SERVICE=${DEFAULT_SERVICE:-rafb} DEFAULT_LANGUAGE=${DEFAULT_LANGUAGE:-Plain Text} DEFAULT_EXPIRATION=${DEFAULT_EXPIRATION:-1 month} |