Re: [PATCH] findprog: Support searching in a specified path string

2019-09-14 Thread Bruno Haible
Hi Paul, > note that > on Windows, which is the only place this matters, so far, IIRC it is > illegal to use "prog.exe.exe" so if an extension is already provided > the system won't search again Indeed, the native Windows execlp() function behaves like this: - If the caller specifies "prog.exe

Re: [PATCH] findprog: Support searching in a specified path string

2019-09-10 Thread Paul Smith
On Mon, 2019-09-09 at 20:54 +0200, Bruno Haible wrote: > -extern const char *find_in_given_path (const char *progname, const char > *path); > + - Otherwise, it returns NULL. > + If OPTIMIZE_FOR_EXEC is true, the function saves some work, under the > + assumption that the resulting pathname w

Re: [PATCH] findprog: Support searching in a specified path string

2019-09-09 Thread Bruno Haible
Paul Smith wrote: > Having PATH= be equivalent to PATH=., and even > moreso "unset PATH" be equivalent to PATH=., is quite odd IMO. It is just as odd as the fact that PATH=:/bin is equivalent to PATH=.:/bin and PATH=/bin: is equivalent to PATH=/bin:. > > > My personal opinion is that it's not

Re: [PATCH] findprog: Support searching in a specified path string

2019-09-08 Thread Paul Smith
On Sun, 2019-09-08 at 19:48 +0200, Bruno Haible wrote: > > My suggestion was that BOTH these functions should not assume the CWD > > if PATH is empty or missing, not that they should behave differently. > > OK. But what, do you suggest, should the functions do when confronted to > an empty path? W

Re: [PATCH] findprog: Support searching in a specified path string

2019-09-08 Thread Bruno Haible
Hi Paul, > > > I find that VERY odd, and possibly a security risk. According to > > > POSIX, the behavior if PATH is not present or is empty is > > > implementation-defined and my preference/expectation would be to behave > > > as if the program is not found. However, that's a different > > > di

Re: [PATCH] findprog: Support searching in a specified path string

2019-09-08 Thread Paul Smith
On Sun, 2019-09-08 at 16:59 +0200, Bruno Haible wrote: > Hi Paul, > > > > > prog = find_in_path_str ("myprog", lookup_path ()); > > > > > > > > and if lookup_path() returns NULL it defaults to the environment > > > > PATH, > > > > > > I don't think NULL should be interpreted as "look in the

Re: [PATCH] findprog: Support searching in a specified path string

2019-09-08 Thread Bruno Haible
Hi Paul, Here's the implementation I'm committing. I feel that merging the two functions in a single file would add more contortions than benefit. 2019-09-08 Bruno Haible findprog-in: New module. Suggested by Paul Smith . * lib/findprog.h (find_in_given_path): New de

Re: [PATCH] findprog: Support searching in a specified path string

2019-09-08 Thread Bruno Haible
Hi Paul, > > > prog = find_in_path_str ("myprog", lookup_path ()); > > > > > > and if lookup_path() returns NULL it defaults to the environment > > > PATH, > > > > I don't think NULL should be interpreted as "look in the default > > PATH". Rather, the convention is that an empty or null PAT

Re: [PATCH] findprog: Support searching in a specified path string

2019-09-08 Thread Paul Smith
On Sun, 2019-09-08 at 13:38 +0200, Bruno Haible wrote: > > the path search is done > > on the _parent's_ PATH environment value not the one passed in to > > posix_spawnp(). I don't want that, I need the search done in the > > child's environment. I can't decide if this behavior by > > posix_spawn

Re: [PATCH] findprog: Support searching in a specified path string

2019-09-08 Thread Bruno Haible
Hi Paul, > I'm addressing https://savannah.gnu.org/bugs/?56834 > > I want to invoke a child process, and I need the program I'm going to > invoke to be searched for in a PATH which is (potentially) different > than the PATH which is active in the parent. > > When you use execlp(), you can just a

Re: [PATCH] findprog: Support searching in a specified path string

2019-09-07 Thread Paul Smith
On Sat, 2019-09-07 at 12:42 +0200, Bruno Haible wrote: > Hi Paul, > > find_prog_in_path() always uses the PATH value in the current > > environment. It can be very useful to search for programs on > > a path without having to modify the environment first. > > > > Provide find_in_path_str() which

Re: [PATCH] findprog: Support searching in a specified path string

2019-09-07 Thread Bruno Haible
Hi Paul, > find_prog_in_path() always uses the PATH value in the current > environment. It can be very useful to search for programs on > a path without having to modify the environment first. > > Provide find_in_path_str() which takes a path string to search. > If the path passed in is NULL, fa

Re: [PATCH] findprog: Support searching in a specified path string

2019-09-06 Thread Paul Smith
I don't know if people would prefer to actually define two real functions one of which just invokes the other, rather than use a preprocessor macro to forward the old one to the new one. I'm fine with it either way. On Fri, 2019-09-06 at 19:10 -0400, Paul Smith wrote: > find_prog_in_path() alway

[PATCH] findprog: Support searching in a specified path string

2019-09-06 Thread Paul Smith
find_prog_in_path() always uses the PATH value in the current environment. It can be very useful to search for programs on a path without having to modify the environment first. Provide find_in_path_str() which takes a path string to search. If the path passed in is NULL, fall back to searching i