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:07:55 -0400
User-agent: Mozilla Thunderbird

On 5/13/24 7:47 PM, Koichi Murase wrote:
2024年5月13日(月) 19:38 Matheus Afonso Martins Moreira
<matheus.a.m.moreira@gmail.com>:
The PATH variable is hard coded in the user command finder function.
Transforming it into an argument allows reusing the file finding logic
with variables other than PATH, making the code more flexible.

I think what was suggested by Chet is to confine the changes in
builtins/source.def. The patches touch the interface of many
functions, but it seems essentially equivalent to just calling

   find_in_path (list->word->word, path_value ("BASH_SOURCE_PATH", 1),
FS_READABLE);

More or less, but you have to check whether path_value() returns NULL,
indicating that the variable is unset. This only really matters if
`source' acquires an option to enable using BASH_SOURCE_PATH, in which
case it should fail if the variable is unset (I remain unconvinced that
this is necessary), otherwise you just use $PATH as normal.


The cases where path_value() returns NULL or an empty string would be
anyway handled by find_in_path()

path_value() won't return an empty string.

--
``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]