This is the mail archive of the
mailing list for the Cygwin project.
Re: Use a default path in exec*p*() if PATH is unset?
Thomas Wolff wrote:
Am 10.04.2017 um 22:29 schrieb Christian Franke:
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 -`
Why does it `env -i` at all?
I guess because make result should not depend on environment. I agree
that 'env -i' is probably to much, 'env -u CC' would be enough.
(And why does it prepend a \ to the output?)
It doesn't. The extra \\ is required because `...` is used instead of
$ printf "all:\\n\\t@echo \\\$(CC)\\n"
$ CC=$(printf "all:\\n\\t@echo \\\$(CC)\\n" > /dev/tty)
$ CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" > /dev/tty`
It seems this scriptlet has an issue, rather than adapting core
behaviour for it.
Of course Cygwin shouldn't be adapted solely for this single case.
But it possibly Cygwin should be adapted to the existing practice of
various other open source *ix systems.
Interestingly the approach in newlib/libc/posix/execvp.c differs from
Cygwin and others:
execvp() with PATH unset calls execv(). This has the same effect as
execvp() with PATH set to current directory only.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple