Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Overriding "builtin"
- X-seq: zsh-users 27943
- From: "Daniel Shahaf" <d.s@xxxxxxxxxxxxxxxxxx>
- To: Đoàn Trần Công Danh <congdanhqx@xxxxxxxxx>, "Zach Riggle" <zachriggle@xxxxxxxxx>
- Cc: "Zsh Users" <zsh-users@xxxxxxx>
- Subject: Re: Overriding "builtin"
- Date: Fri, 12 Aug 2022 07:12:56 +0000
- Archived-at: <https://zsh.org/users/27943>
- Feedback-id: i425e4195:Fastmail
- In-reply-to: <YvW5xVGPG4Y4OLGk@danh.dev>
- List-id: <zsh-users.zsh.org>
- References: <CAMP9c5k1C8GmB+LE56J+o7xv2HDwHRApCHqrx0=NK93yh=BEUQ@mail.gmail.com> <YvW5xVGPG4Y4OLGk@danh.dev>
Đ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