I was reading a shell script today and came across the trap command, which I was not aware of. Some googling led me to this article: How “Exit Traps” Can Make Your Bash Scripts Way MoreRobust And Reliable , which has a really nice explanation. Basically, trap acts sort of like a finally block in a try/catch pattern. Very useful for shutting down services, cleaning up temp files and such. I think that trap is specific to BASH, so you can’t use it with plain old Bourne shell, but just about every UNIX has BASH nowadays, so I don’t think it is a problem.
UNIX tip of the day – trap EXIT
Join 165 other subscribers
archives
Category
- ▼Computers (132)
- ►(x)html (19)
- ►bash (9)
- ►css (13)
- ►elasticsearch (1)
- ►git (1)
- ►hardware (3)
- ►java (2)
- ►javascript (12)
- ►latex (29)
- ►linux (25)
- ►lucene (1)
- ►mac osx (10)
- ►perl (8)
- ►php (18)
- ►python (4)
- ►regex (4)
- ►software development (4)
- ►solr (1)
- ►sql (9)
- ►svn (1)
- ►UNIX (12)
- ►vim (1)
- ►wiki/cms (11)
- ▼WordPress (56)
- (Un)verified
- 2 new versions of postie released
- BBpress forums and wordpress plugin development versions
- Blogging with LaTeX
- Cherry rhubarb pie
- Closures in PHPUnit dataProviders
- Collaping categories 0.6.1
- Collapse all the things!
- Collapsing archives updated
- Collapsing categories update
- Collapsing monopoly
- Collapsing updates galore
- Design details
- Exploring querying parquet with Hive, Impala, and Spark
- Forcing JPEG instead of WebP for images with Jetpack
- Found in Translation
- Friendfeed plugin for wordpress
- Getting ready for wordpress 2.8
- Git tip – restoring “lost” commits
- I am now an automattician!
- Multi-column balanced lists
- New wordpress plugin – category reminder
- New Wordpress plugin – Image Browser
- New wordpress plugin – Image Meta
- On blog navigation
- Photos, EXIF, IPTC oh my!
- Picasa 3 collages
- Postie 1.3.0 released
- Postie 1.4.2 released
- Posting with QTM
- Random featured images in wordpress
- Reading iptc captions from jpegs with imagemagick
- Releasing Postie 1.3.alpha, packed with new features
- Releasing the Collapsing Archives Wordpress Plugin
- Releasing the Collapsing Categories Wordpress Plugin
- Site redesign
- The importance of the denominator and a nutrition experiment
- The right 3 bytes OR wordpress plugin bugs solved
- Thinking, waiting, fasting
- TIL: Elasticsearch timeouts
- Trying out bbpress
- trying out scribefire
- UNIX tip of the day – trap EXIT
- UNIX tip of the day: Inserting files with sed
- UNIX Tip of the day: simple backups
- UNIX tip of the day: two file processing with AWK
- UNIX tip of the day: units
- Website history, redesign, and relaunch
- What is a professor?
- WordCamp Europe
- wordpress 2.8 is out, and my plugins are ready
- Wordpress 2.9 image changes
- WordPress tip of the day: listing all filters
- wordpress, mediarss, and friendfeed
- Writing your own custom filters for postie
- Yet another website re-design
- ►(x)html (19)
- ►cooking (44)
- ►environmentalism (4)
- ►general (17)
- ►linguistics (15)
- ►mindfulness (4)
- ►music (2)
- ►photography (15)