Y
Hacker News
new
|
ask
|
show
|
jobs
by
Galanwe
449 days ago
FYI, have a look at "trap .. EXIT" to defer cleanups like your unlink. It's neat cause it will run even if the script is interrupted / fails before the unlink.
1 comments
lioeters
449 days ago
Useful tip, I suppose it will look like:
temp=$(mktemp) trap 'unlink $temp' EXIT # Do things
link
Galanwe
449 days ago
Exactly. And if your cleanup is more involved you can call a cleanup function.
link