Thanks. I've found a less invasive solution – to name all inner functions witu tmp/… prefix, and unset them with nset -f -m tmp/\* On Fri, 24 Feb 2023 at 23:41, Bart Schaefer wrote: > On Thu, Feb 23, 2023 at 6:10 PM Sebastian Gniazdowski > wrote: > > > > I want to automatically clear all functions created from outer function. > > > > Any ideas on having such auto-unset-funcs function? > > Unclear what side-effect messing about with localtraps may have on > this, but you can use one EXIT trap to set another EXIT trap: > > inner () { > trap "print FROM INNER: \$0; trap 'print FROM OUTER: \$0' EXIT" EXIT > } > outer () { > inner > } > > % outer > FROM INNER: outer > FROM OUTER: Src/zsh > > > Getting the quoting right for something more complicated, is left as > an exercise. > -- Best regards, Sebastian Gniazdowski