[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Re: [PATCH v2 1/8] findcmd: parameterize path variable in functions
From: |
Matheus Afonso Martins Moreira |
Subject: |
Re: Re: [PATCH v2 1/8] findcmd: parameterize path variable in functions |
Date: |
Tue, 14 May 2024 03:32:34 +0000 |
> The patches touch the interface of many functions
I added one external function: find_in_path_var.
The other changes are all static and local.
> It seems essentially equivalent to just calling
> find_in_path (list->word->word, path_value ("BASH_SOURCE_PATH", 1),
> FS_READABLE);
It is. I'm just very averse to chaining functions like that in C
since you can't write f(g(x)) without worrying about freeing
the value returned by g. For that reason I think this is better:
find_in_path_var (list->word->word, "BASH_SOURCE_PATH", FS_READABLE);
Also, find_in_path is itself just a wrapper for a static function,
just like find_in_path_var. I followed the same approach.
> The cases where path_value() returns NULL or an empty string would be
> anyway handled by find_in_path()
With find_in_path_var there's no need to even consider that.
The knowledge of those cases has been captured by the function.
There's no need to explicitly use path_value either.
> I doubt it's worth adding those changes in
> `findcmd.c'. So are the changes in [PATCH v2 2/8].
You don't think they improve the code?
-- Matheus
Re: Re: [PATCH 0/9] Add library mode to source builtin, Matheus Afonso Martins Moreira, 2024/05/05
[PATCH v2 0/8] Add isolated mode to source builtin, Matheus Afonso Martins Moreira, 2024/05/13
Re: [PATCH v2 1/8] findcmd: parameterize path variable in functions, Chet Ramey, 2024/05/14
Re: [PATCH v2 1/8] findcmd: parameterize path variable in functions, Chet Ramey, 2024/05/14
Re: [PATCH v2 1/8] findcmd: parameterize path variable in functions, Matheus Afonso Martins Moreira, 2024/05/14
Re: [PATCH v2 1/8] findcmd: parameterize path variable in functions, Matheus Afonso Martins Moreira, 2024/05/14
Re: [PATCH v2 1/8] findcmd: parameterize path variable in functions, Chet Ramey, 2024/05/15