aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-05-09 00:40:12 +0800
committertypebrook <typebrook@gmail.com>2020-05-09 00:40:12 +0800
commit2331663bbe28c789cf977c627e5ec9faa06043c7 (patch)
tree1af560050bb842cc38ac1f0c03ebff5ff5a0aeaf
parentd2bb4b1881d45e42f9aca0e08aeb601dca0f02d5 (diff)
Add option to debug with log
-rwxr-xr-xgist3
1 files changed, 2 insertions, 1 deletions
diff --git a/gist b/gist
index ab4be9f..d07ed3c 100755
--- a/gist
+++ b/gist
@@ -76,7 +76,7 @@ set -o pipefail
76 76
77# clean temporary files 77# clean temporary files
78tmp_dir=$(mktemp -d) 78tmp_dir=$(mktemp -d)
79trap "rm -r $tmp_dir" EXIT 79trap "[[ '$DEBUG' == 'true' ]] && find $tmp_dir -type f | xargs tail -n +1 > log; rm -r $tmp_dir" EXIT
80 80
81# Mac compatibility 81# Mac compatibility
82tac() { 82tac() {
@@ -124,6 +124,7 @@ http_method() {
124 [[ $METHOD =~ (POST|PATCH) ]] && data_opt="@$http_data" 124 [[ $METHOD =~ (POST|PATCH) ]] && data_opt="@$http_data"
125 http -b "$METHOD" "$@" "$header" "$data_opt" ;; 125 http -b "$METHOD" "$@" "$header" "$data_opt" ;;
126 esac 2>&1 \ 126 esac 2>&1 \
127 | tee $(mktemp -p $tmp_dir) \
127 || { echo "Error: no active internet connection" >&2; return 1; } 128 || { echo "Error: no active internet connection" >&2; return 1; }
128} 129}
129 130