bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Call dynamic builtins with 'builtin' command


From: Greg Wooledge
Subject: Re: Call dynamic builtins with 'builtin' command
Date: Sat, 12 Oct 2024 17:18:47 -0400

On Sat, Oct 12, 2024 at 16:55:31 -0400, Chet Ramey wrote:
> On 10/9/24 7:15 AM, Vadim Nevorotin wrote:
> > 2. Can you explain how to load and use e.g. stat builtin without
> > overwriting the current behavior of stat in the whole existing script?
> 
> Is this anything more complicated than doing
> 
> enable it
> use it
> disable it

Another way would be something like:

1. Save the output of type -p stat in a variable.
2. Enable the builtin.
3. Write a stat() wrapper function that calls either the builtin stat or
   the external stat program, based on whatever unspecified criteria
   you are using to switch between the two.

If you tell us why you want to switch back and forth between the two
implementations within a script, we might be able to give more focused
advice.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]