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

Re: Overriding "builtin"



On 2022-08-11 20:18:49-0500, Zach Riggle <zachriggle@xxxxxxxxx> wrote:
> I recently learned that 'builtin' can be overridden with a function.  Neat
> for some silly tricks!
> 
> However, is there a way to save / restore 'builtin' such that it can be
> restored?
> 
> All that I can think of is 'unfunction builtin', but 'unfunction' itself
> can be overridden with a function.

You can run original builtin with "builtin".

e.g.:

echo() { printf '++%s\n' "$@"; }
echo this will run function
builtin echo this will run builtin

-- 
Danh




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