Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: zsh-3.1.5-pws-9, TRAPZERR fix for new completion



On Feb 21, 10:40am, Matt Armstrong wrote:
} Subject: Re: PATCH: zsh-3.1.5-pws-9, TRAPZERR fix for new completion
}
} As far as restoring it, Do'h!  I thought I tested that, but obviously 
} not.  Is there an easy way to bind a function to a different name and
} restore it?  I've tried games with stuff like foo=$(functions TRAPZERR) 
} ... eval $foo, but that seems suboptimal.

You can do

zsh% eval newname "$(functions oldname)"
zsh% oldname() { ...  }
zsh% eval oldname "$(functions newname)"
zsh% unfunction newname

as long as newname is unique and oldname isn't awaiting autoload.

For traps, if you use the "trap" builtin instead of a TRAPxxx() function,
the trap is automatically removed at the end of the local scope.  That
does not restore any outer-scope traps, though (global-scope TRAPxxx() is
deleted by local-scope "trap ... xxx" commands).

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author