concept

Inspect trap actions

Print installed trap actions in reusable shell syntax. Output can disclose sensitive actions; inspect only trusted fixtures.

Formal Syntax & Structure

bash syntaxbash
trap -p [event ...]

Return Value

exit status

Print installed trap actions in reusable shell syntax. Output can disclose sensitive actions; inspect only trusted fixtures.

Working Example

Example Snippetbash
trap ':' RETURNif [[ -n $(trap -p RETURN) ]]; then printf 'installed\n'; fitrap - RETURNif [[ -z $(trap -p RETURN) ]]; then printf 'reset\n'; fi
Bash Reference