delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/08/08/20:17:40

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:from:to:references:in-reply-to:subject:date
:message-id:mime-version:content-type:content-transfer-encoding;
q=dns; s=default; b=Hq/kP+foqSYhiiUHsxLwlAwUUGk2UPyzA8Q59nAH8i5
naxsVNF5hLsKiNah6kCYs6AgyK+NlfOeUIYMJAg9ZdtrCT7rm45edyeHA9v13FUX
htnFSdMb2mEceqSNN/RgZPAjnOVGO5EHXtvyeoHRIEtv453zts+Czovb6QHMNNd0
=
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:from:to:references:in-reply-to:subject:date
:message-id:mime-version:content-type:content-transfer-encoding;
s=default; bh=ls4SEUNNB6uLT7np3rYG6s7XfNg=; b=ZfOgKFaF3sAyWcrk4
N9iPw8llnwxnpXJWNF8gUB6F/8756BgsCzQekYsU+SVLv42uR7rT7JmTdEnbMc98
kLia8rPauf9CcGjW0zT5V04PIfRJWGPoBAIRZgl/kgfqiymCTPHnUFSRtwHIgwu8
KA8k2Da1xRsySicthnfx31DOQ8=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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=2.8 required=5.0 tests=AWL,BAYES_00,CYGWIN_OWNER_BODY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=HContent-Language:en-ca, H*UA:Outlook, H*x:Outlook, H*UA:Microsoft
X-HELO: nm5-vm7.access.bullet.mail.bf1.yahoo.com
X-Yahoo-SMTP: _oUbE.SswBCQ_d_LvSIk7sZfv6R7Is8n9OVRVjJJh3dhqEgGPCs-
From: "Michel LaBarre" <michel DOT labarre AT rogers DOT com>
To: <cygwin AT cygwin DOT com>
References: <001001d1edf1$a4e1ae90$eea50bb0$@rogers.com> <1C0AE95E-0118-4353-AA77-4D41F1AE9AE1 AT solidrocksystems DOT com> <001a01d1eea9$f7949a90$e6bdcfb0$@rogers.com> <76ec05e9-140a-19cb-942b-698582c3d024 AT gmail DOT com> <001f01d1ef2c$f04af9e0$d0e0eda0$@rogers.com> <20160805152951 DOT GO25811 AT calimero DOT vinschen DOT de> <57A6ED1C DOT 1060402 AT gmx DOT de> <20160808112321 DOT GF32150 AT calimero DOT vinschen DOT de> <e90174df-61b4-17c8-064b-30009e6ad559 AT gmail DOT com> <20160808143321 DOT GS25811 AT calimero DOT vinschen DOT de>
In-Reply-To: <20160808143321.GS25811@calimero.vinschen.de>
Subject: RE: PATHEXT is fundamental to Windows and Should be recognised by CYGWIN
Date: Mon, 8 Aug 2016 20:17:09 -0400
Message-ID: <000301d1f1d3$5f620d70$1e262850$@rogers.com>
MIME-Version: 1.0
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id u790HZ6E022000


-----Original Message-----
From: cygwin-owner AT cygwin DOT com [mailto:cygwin-owner AT cygwin DOT com] On Behalf Of Corinna Vinschen
Sent: August-08-16 10:33 AM
To: cygwin AT cygwin DOT com
Subject: Re: PATHEXT is fundamental to Windows and Should be recognised by CYGWIN

On Aug  8 09:43, cyg Simple wrote:
> On 8/8/2016 7:23 AM, Corinna Vinschen wrote:
> > On Aug  7 10:11, Herbert Stocker wrote:
> >> On 05.08.2016 17:29, Corinna Vinschen wrote:
> >>  If you see the
> >>> code required to handle .exe and .lnk extensions you don't *want*
> >>> PATHEXT support anymore.
> >>>
> >>
> >> Moreso, this code has recently broken my C++ code in Cygwin.
> >> It tried to see if a directory  /dir/subdir/something  existed,
> >> and Cygwin said yes because it found a /dir/subdir/something.exe .
> >> So my program failed.
> > 
> > I have some doubt here.  Cygwin always checks for "foo" first.
> > Only if it doesn't find "foo", it checks for "foo.exe", then
> > for "foo.lnk" and last, for backward compat, for "foo.exe.lnk".
> > 
> 
> Which is the exact cause of the issue.
> 
> > In the POSIX realm, "foo" == "foo.exe" == "foo.lnk".  The search itself
> > is indiscriminately, because Cygwin can't know if you're looking for
> > "foo" or "foo.exe" or a symlink "foo" using the .lnk suffix.
> 
> Why do you say "In the POSIX realm"?  Only Cygwin does this association.
>  I understand why it does so but is there a different way to achieve the
> same thing with greater accuracy?  Maybe we don't want the artificial
> symlink of foo == foo.exe all the time.  Maybe it is time we drop the
> artificial symlink altogether in preference for modifying the scripts
> and programs to use .exe when on Windows including Cygwin or perhaps
> creating a real symlink for foo.exe to foo.  Dropping the artificial
> symlink would simplify the code and increase the speed with which it
> executes.
> 
> As for PATHEXT we can do the following scenario instead.
> 
> export PATHEXT="$PATHEXT;.TXT"
> vi foo.txt
> :set ff=dos
> i
> a
> b
> c
> <ESC>
> :wq
> cmd /c foo

As you show here, the PATHEXT definition is so that it also contains
file suffixes which require to know the interpreters starting them.  To
implement that, the lib would have to either read the registry to know
the connection between suffix and interpreter (which is pretty
convoluted), or it would have to "start the file", aka call ShellExecute
on the file, without knowing what process will come up as child process.
In your example that would be Notepad or Write.

The way this works is just not feasible to be used from inside the DLL,
e.g.:

- ShellExecute does not return a handle to the called process, so the
  parent can't wait(2) for it.

- ShellExecute does not allow to specify an environment for the child
  process.  Cygwin's Windows environment is reduced to minimal size.
  Cygwin children inherit the POSIX environment by a simple copy
  process.  Only when starting a non-Cygwin process, this process gets
  a full Windows environment by means of the matching CreateProcess
  parameter.

So, if we actually implement PATHEXT, its usage would be limited to
suffixes of binary files and files starting with #!<interpreter>, or we
would have to use a way to start an application which doesn't work well
in a POSIX scenario, or we would have to search the registry for the
suffix linkage.  Additionally to searching a variable number of files
for each single file access.
[Michel] 
[Michel] #! Is better than nothing but doing PATHEXT fully might put these considerations to rest forever.
[Michel] Fundamentally, the means of invoking a file interpreter in Windows are determined by the registry's file associations;
[Michel] anything else is an assumption.
[Michel] I don't know how cygwin.dll is implemented but the only suffixes that need to be looked up are the ones in PATHEXT and that could be done once could it not?  

Additionally I would (again?) like to stress that PATHEXT is a feature
of CMD, aka, the shell.  It's not a feature of the underlying libs.
[Michel] 
[Michel] PATHEXT is supported by Powershell and VBS.  MKS's shells (ksh,sh,perl) also.  
[Michel] Likely others since it is considered consistent with Windows.
[Michel] It likely should have been implemented at a lower level but was not.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat


--
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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019