no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


blog:2022:06:04:2022-06-04_-_bash_and_raii_-_continued [2022/06/04 20:20] (current) – created basz
Line 1: Line 1:
 +====== 2022-06-04 - bash and RAII - continued ======
  
 +couple days ago i wrote about [[:blog:2022:05:29:2022-05-29 - bash and RAII|RAII in bash]]. i forgot to mention 1 more thing there. when cleanup procedure is more complicated than simple ''rm -rf foobar'' it's worth to make it a separate function:
 +
 +<code bash>
 +# ...
 +function cleanup
 +{
 +  rm -rf "$VAR_TO_SANITIZE"
 +  rm -fv /path/to/lock
 +  umount /media/foobar
 +}
 +trap cleanup EXIT
 +# ...
 +</code>
blog/2022/06/04/2022-06-04_-_bash_and_raii_-_continued.txt · Last modified: 2022/06/04 20:20 by basz
Back to top
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0