summaryrefslogtreecommitdiff
path: root/Setting traps.md
blob: cd36e8024ca474f02cb7b41d45cbdbcbdeb49b85 (plain)
1
2
3
4
5
6
7
8
9
10
---
tags:
  - bash
---
With traps you can configure a function that is run upon a specific signal or when the script fails or exits normally.

`trap fn ERR` > when an error occurrs
`trap fn EXIT` > any exit, also errors and interrupts
`trap fn SIGINT` > when interrupted
`trap fn ERR SIGINT` > either an interrupt or error occurred