Web lists-archives.com

Use a default path in exec*p*() if PATH is unset?




A few years after https://cygwin.com/ml/cygwin/2014-09/msg00204.html
I found another use case of an unset PATH variable:

The configure script from mandoc (http://mdocml.bsd.lv/) uses this interesting approach to query default CC command from make:

CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | env -i make -sf -`

This works at least on Linux, (Free|Net|Open)BSD and OpenIndiana. It fails on Cygwin because 'env -i' unsets everything and execvp() does not use a default path then. This is OK from the POSIX ("implementation-defined") point of view but differs from existing practice.

At least some Linux distros use ".:/bin:/usr/bin" as default path (https://linux.die.net/man/3/exec). Including the current directory is IMO a bad idea.

This is apparently inherited from the early days:
The current directory is included on current Debian stable, and
[... time travel ...]
also
[... time travel ...]
on Slackware 1.0.1 from 1993 :-)
(Thanks to http://www.qemu-advent-calendar.org/2014/ for this image)

Other OS typically use a default path without current directory.

Should Cygwin also use a default path, for example _PATH_DEFPATH=/bin ?

Christian


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple