projg2 / python-exec

Wrapper for multi-implementation install of Python scripts and executables
BSD 2-Clause "Simplified" License
13 stars 6 forks source link

src/python-exec.c: utilize confstr(_CS_PATH) if PATH is unset #2

Closed floppym closed 7 years ago

floppym commented 7 years ago

exec(3) from glibc says:

The execlp(), execvp(), and execvpe() functions duplicate the actions of the shell in searching for an executable file if the specified filename does not contain a slash (/) character. The file is sought in the colon-separated list of directory pathnames specified in the PATH environment variable. If this variable isn't defined, the path list defaults to the current directory followed by the list of directories returned by confstr(_CS_PATH). (This confstr(3) call typically returns the value "/bin:/usr/bin".)

floppym commented 7 years ago

An alternative to this would be to hard-code a fallback PATH setting, probably based on a configure option.

mgorny commented 7 years ago

To be honest, I'm not convinced this is the best things to do. Citing POSIX:

If this environment variable is not present, the results of the search are implementation-defined.

This variable certainly isn't POSIX, and the glibc behavior is at best debatable. I certainly don't think it a good idea to use CWD like this.

mgorny commented 7 years ago

FreeBSD, Darwin:

If this variable is not specified, the default path is set according to the _PATH_DEFPATH definition in , which is set to ``/usr/bin:/bin''. For execvP(), the search path is specified as an argument to the function. In addition, certain errors are treated specially.

Solaris manpage doesn't mention fallback at all.

floppym commented 7 years ago

Per our IRC conversation, I will open a new PR with a configure option for this instead.