diff options
author | Bo Ørsted Andresen <zlin@exherbo.org> | 2009-12-16 18:15:12 +0000 |
---|---|---|
committer | Bo Ørsted Andresen <zlin@exherbo.org> | 2009-12-16 18:15:12 +0000 |
commit | 9e550207c87ae1019e87f7f05a87fe8c2e3beea2 (patch) | |
tree | 1ecbc2b40aa4a6cbb8676bdba20b55c356d89ee7 | |
parent | 29cb3ce9e58078c30f367db462c5befd405fdc28 (diff) | |
download | wgetpaste-9e550207c87ae1019e87f7f05a87fe8c2e3beea2.tar.gz |
Indent section one tab.
-rwxr-xr-x | wgetpaste | 53 |
1 files changed, 27 insertions, 26 deletions
@@ -731,36 +731,37 @@ warnings >&2 # set recipient RECIPIENT=$(getrecipient RAW) -# create temp file (wget is much more reliable reading large input via --post-file rather than --post-data) -[[ -f $TMPF ]] || TMPF=$(mktemp /tmp/wgetpaste.XXXXXX) -if [[ -f $TMPF ]]; then - postdata > "$TMPF" || die "Failed to write to temporary file: \"$TMPF\"." - WGETARGS="--post-file=$TMPF" -else - # fall back to using --post-data if the temporary file could not be created - # TABs and new lines need to be escaped for wget to interpret it as one string - WGETARGS="--post-data=$(postdata | sed -e 's|$|%0a|g' -e 's|\t|%09|g' | tr -d '\n')" -fi - -# paste it -WGETARGS="--tries=5 --timeout=60 $WGETARGS" -if geturl needstdout || [[ $DEBUG || ! -w /dev/null ]]; then - OUTPUT=$(LC_ALL=C wget -O - $WGETARGS $RECIPIENT 2>&1) -else - OUTPUT=$(LC_ALL=C wget -O /dev/null $WGETARGS $RECIPIENT 2>&1) -fi + # create temp file (wget is much more reliable reading + # large input via --post-file rather than --post-data) + [[ -f $TMPF ]] || TMPF=$(mktemp /tmp/wgetpaste.XXXXXX) + if [[ -f $TMPF ]]; then + postdata > "$TMPF" || die "Failed to write to temporary file: \"$TMPF\"." + WGETARGS="--post-file=$TMPF" + else + # fall back to using --post-data if the temporary file could not be created + # TABs and new lines need to be escaped for wget to interpret it as one string + WGETARGS="--post-data=$(postdata | sed -e 's|$|%0a|g' -e 's|\t|%09|g' | tr -d '\n')" + fi -# clean temporary file if it was created -if [[ -f $TMPF ]]; then - if [[ $DEBUG ]]; then - echo "Left temporary file: \"$TMPF\" alone for debugging purposes." + # paste it + WGETARGS="--tries=5 --timeout=60 $WGETARGS" + if geturl needstdout || [[ $DEBUG || ! -w /dev/null ]]; then + OUTPUT=$(LC_ALL=C wget -O - $WGETARGS $RECIPIENT 2>&1) else - rm "$TMPF" || echo "Failed to remove temporary file: \"$TMPF\"." >&2 + OUTPUT=$(LC_ALL=C wget -O /dev/null $WGETARGS $RECIPIENT 2>&1) + fi + + # clean temporary file if it was created + if [[ -f $TMPF ]]; then + if [[ $DEBUG ]]; then + echo "Left temporary file: \"$TMPF\" alone for debugging purposes." + else + rm "$TMPF" || echo "Failed to remove temporary file: \"$TMPF\"." >&2 + fi fi -fi -# get the url -URL=$(geturl "$OUTPUT") + # get the url + URL=$(geturl "$OUTPUT") # verify that the pastebin service did not return a known error url such as toofast.html from rafb verifyurl |