2022-06-04 - bash and RAII - continued

couple days ago i wrote about 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:

# ...
function cleanup
  rm -rf "$VAR_TO_SANITIZE"
  rm -fv /path/to/lock
  umount /media/foobar
trap cleanup EXIT
# ...
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