Employers: discover CodinGame for tech hiring
EVENTS
UPCOMING
PAST
SOLO
PUZZLES
CODE GOLF
OPTIMIZATION
MULTI
LEADERBOARDS
CLASH OF CODE
BOT PROGRAMMING
CODING ESCAPE
COMMUNITY
CONTRIBUTIONS
LEARN
DISCORD
FORUM
LIVE STREAMS
Log In
Sign Up
Bash traps
zlutystrop
432 views
#!/usr/bin/env bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function cleanup() {
RM=$1
printf "====TRAP====\nDoing some cleanup...\n"
# ...
printf "OK.\n"
exit 0
}
printf "The script runs here...\n"
trap cleanup EXIT
printf "...and also here.\n"
Run
0
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
Suggested playgrounds
Java shutdown hook
By
zlutystrop
494
3
0
Python atexit
By
zlutystrop
1,260
10
0
Python from Zero to Hero
By
toEpam
7,948
94
0
Programando C++
By
segas
53
1
0
ABOUT US
CAREERS
PRIVACY
FAQ
BLOG
ABOUT US
CAREERS
PRIVACY
FAQ
BLOG
The #1 tech hiring platform
SCREENING
INTERVIEWING
Facebook
YouTube
Twitter
LinkedIn
FR
EN