bug-bash
[Top][All Lists]
Advanced

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

Re: [PATCH v2 1/8] findcmd: parameterize path variable in functions


From: Chet Ramey
Subject: Re: [PATCH v2 1/8] findcmd: parameterize path variable in functions
Date: Tue, 14 May 2024 16:14:42 -0400
User-agent: Mozilla Thunderbird

On 5/13/24 11:32 PM, Matheus Afonso Martins Moreira wrote:
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.

In this case, it's easy to look at other callers of path_value(), or at
path_value() itself (it's what, 8 lines?) to determine whether it returns
static memory -- which it does.

Anyway, there isn't any real reason to modify findcmd.c. Everything this
needs is already available.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

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