Files
oam/knowledge base/trap.md
2023-07-09 21:35:14 +02:00

607 B

The Bash trap command

Table of contents

  1. TL;DR
  2. Sources

TL;DR

# Run a command or function on exit, kill or error.
trap "rm -f $tempfile" EXIT SIGTERM ERR
trap function-name EXIT SIGTERM ERR

# Disable CTRL-C
trap "" SIGINT

# Re-enable CTRL-C
trap - SIGINT

Sources