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
413 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
Python atexit
By
zlutystrop
1,196
10
0
Java shutdown hook
By
zlutystrop
467
3
0
Python from Zero to Hero
By
toEpam
7,337
85
0
Exercice Javascript
By
StevenHanse
23.4K
313
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