Recently Written · git

tmpl

Insanely simple templates

git clone https://github.com/equwal/tmpl

Log | Files | Refs


sh/trap/progress-cleanup (349 bytes)

1 # Show progress and clean up on interruption
2 current_task=""
3 
4 progress_cleanup() {
5     if [ -n "$current_task" ]; then
6         echo "Interrupted during: $current_task" >&2
7     fi
8     <++>
9     exit 1
10 }
11 
12 trap progress_cleanup TERM INT
13 
14 # Set current_task before each major operation
15 current_task="<++>"
16 <++>
17 
18 current_task="<++>"
19 <++>
20 
21 current_task=""