X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=F10+G170kXltTXhu NVMKkUjVrHao4tcXI/sYl9GtLv3sUwWkHIyQ7F4YT4JLgPHyejC4xm+Kli1hZ06f bygmSWMFxuIDgC8sr3VtsRLpP7CE7Uqg0WOmp87p56iwK5MAuImANp8SONU/LNZ7 HajLjk9Yhg3zewIL5FNP0M5u290= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=rMvaTbhoZnqfyuSsFPTF8D d+o5g=; b=Rjd0jthP9dUutZ0ruTJjetxrqfOXhCtgpXkaG5WC71gvbp9YTBMvn9 8nY1vI5d86zUOpodN3ZcsD9dwOYhTShyb67HIntRgbIymAoFeAY66ZfGvwCb0UJL M0H9epdP97ScwWu6mBoH4OSM4ygvp4iIbfAWixWSL2bdTnWcBv/wk= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=adapted, HX-HELO:sk:mailout, H*MI:sk:ae107c0, H*i:sk:ae107c0 X-HELO: mailout03.t-online.de Subject: Re: Use a default path in exec*p*() if PATH is unset? To: cygwin AT cygwin DOT com References: From: Christian Franke Message-ID: <7b94712a-465d-421b-bc76-720e443708d3@t-online.de> Date: Tue, 11 Apr 2017 13:10:49 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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 AT 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 AT echo \\\$(CC)\\n" all: @echo \$(CC) $ CC=$(printf "all:\\n\\t AT echo \\\$(CC)\\n" > /dev/tty) all: @echo \$(CC) $ CC=`printf "all:\\n\\t AT echo \\\$(CC)\\n" > /dev/tty` all: @echo $(CC) > 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. 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