Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Forcing cleanup code in shell scripts?



Is it possible to trap Ctrl-C and run some cleanup code in a shell  
script? How would I do that?

I've got this shell script for setting up a gentoo embedded  
environment, and it mounts a few directories, then chroots. If it  
runs successfully, it umounts when done, but if it fails, it doesn't  
run the umounts. Then I fix whatever bug it was that caused it to  
fail, and rm -rf that directory to start again from scratch. And that  
deletes my /usr/portage tree, and I get pissed and waste time.

Any ideas?





BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org