diff options
author | typebrook <typebrook@gmail.com> | 2020-05-09 00:40:12 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-05-09 00:40:12 +0800 |
commit | 2331663bbe28c789cf977c627e5ec9faa06043c7 (patch) | |
tree | 1af560050bb842cc38ac1f0c03ebff5ff5a0aeaf | |
parent | d2bb4b1881d45e42f9aca0e08aeb601dca0f02d5 (diff) |
Add option to debug with log
-rwxr-xr-x | gist | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -76,7 +76,7 @@ set -o pipefail | |||
76 | 76 | ||
77 | # clean temporary files | 77 | # clean temporary files |
78 | tmp_dir=$(mktemp -d) | 78 | tmp_dir=$(mktemp -d) |
79 | trap "rm -r $tmp_dir" EXIT | 79 | trap "[[ '$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 |
82 | tac() { | 82 | tac() { |
@@ -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 | ||