trap-event
RETURN
Run when a function or sourced script finishes in a traced context. Not a failure notification; inheritance can be enabled by functrace.
Formal Syntax & Structure
bash syntaxbash
trap action RETURNReturn Value
event
Run when a function or sourced script finishes in a traced context. Not a failure notification; inheritance can be enabled by functrace.
Working Example
Example Snippetbash
work() { printf 'work\n'; }trap 'printf "returned\n" >&2' RETURNset +Tworkset -Tworktrap - RETURNwork