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

Re: Overriding "builtin"



Đoàn Trần Công Danh wrote on Fri, 12 Aug 2022 02:24 +00:00:
> 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.
>

«unset 'functions[unfunction]'», provided (zsh/parameter is available
and) someone hasn't created an unset() function as well.

> You can run original builtin with "builtin".
>
> e.g.:
>
> echo() { printf '++%s\n' "$@"; }
> echo this will run function
> builtin echo this will run builtin

No, he can't, because in his case that'd be a bottomless recursive call
(= an infinite loop).




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