Skip to content

Commit f54e568

Browse files
authored
Merge pull request #86 from brontitall/temp_file_cleanup
Clean up temp files when metrics_tidy exits cleanly
2 parents 7123a62 + 6116d08 commit f54e568

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

files/metrics_tidy

100644100755
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ fail() {
99
exit 1
1010
}
1111

12+
cleanup() {
13+
rm "$tmp"
14+
}
15+
1216
# Clone, i.e. preserve, original stdout using fd 3.
1317
exec 3>&1
1418
# Send stderr and stdout to a temp file
@@ -18,6 +22,9 @@ exec &>"$tmp"
1822
# Run the fail() method on error
1923
trap fail ERR
2024

25+
# Otherwise cleanup
26+
trap cleanup EXIT
27+
2128
while [[ $1 ]]; do
2229
case "$1" in
2330
'-d'|'--directory')

0 commit comments

Comments
 (0)