Skip to content

Commit

Permalink
Add trap to catch Ctrl+C
Browse files Browse the repository at this point in the history
  • Loading branch information
yubiuser committed Jul 21, 2020
1 parent 88816ac commit 04d337c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pihole_adlist_tool
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,18 @@ remove_temp_database () {
rm -f $TEMP_DB
}

# cleanup on trap
cleanup_on_trap () {
remove_temp_database
echo -e "\\n\\n${bold}User-abort detected!${normal} Removing temporary database.\n"
exit 1
}

### warm-up ######


trap cleanup_on_trap INT

# getopts flags and assing arguments to variables

while getopts 'd:t:s:uh' flag; do
Expand Down

0 comments on commit 04d337c

Please sign in to comment.