Re: [PATCH] fix uneccesary copy of function bodies for BASH_SOURCE
From:
konsolebox
Subject:
Re: [PATCH] fix uneccesary copy of function bodies for BASH_SOURCE
Date:
Tue, 4 Jun 2024 14:10:24 +0800
On Sat, Jun 1, 2024 at 7:16 PM Koichi Murase <myoga.murase@gmail.com> wrote:
>
> ---
> variables.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/variables.c b/variables.c
> index 84b30d93..0e785742 100644
> --- a/variables.c
> +++ b/variables.c
> @@ -3507,7 +3507,11 @@ bind_function_def (const char *name, FUNCTION_DEF
> *value, int flags)
> if (entry && (flags & 1))
> {
> dispose_function_def_contents (entry);
> +
> + cmd = value->command;
> + value->command = 0;
> entry = copy_function_def_contents (value, entry);
> + value->command = cmd;
> }
> else if (entry)
> return;
> --
> 2.45.0
>
Hello,
I haven't looked at this but it will keep lazy functions safe to
implement right?
Lazy functions are functions that redefine themselves the first time
they are called. For example they can call a script containing the
proper implementation with heavier code. Or simplify themselves
depending on the environment or the available tools they detect at
first run.
--
konsolebox