delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/08/08/10:33: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:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=bdza/6JlfmSy6ljMB4v7777TpjkrDnm8xEHo5S5QK6ixOnwXwWCtb
1WD0tFHwnbypcn4/X+QHed21F48ufkzMr8SGbynIXBc446q9HKUKgnHIcsj+PeJX
wPklf/SfuXyFKQdqZICtcQl5WC+eKC9j7/3gDy1/XxU4ChPDSQ3Xro=
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:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=f4CtVGyhPYWiUCn7ZyRyXXqgFKw=; b=kLvLJMeiV3lSMh/n3GSG9H7QYTuL
j0jXFJogw3v2tOw8lk3z9DN6uQHJ4zYD0f/Ke76m2RWynU35RyX4DhSxVp0eXQmh
yiHJR60SVQYjuhuKQfYtFkvcEZMmNeslL2MoWecIBW5iI9e8Od9Vt4ZPgAst+INM
MtV2FrpIcdGjkqY=
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=-94.9 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_BRBL_LASTEXT,RCVD_IN_PBL,RCVD_IN_SORBS_DUL,RDNS_DYNAMIC autolearn=ham version=3.3.2 spammy=
X-HELO: calimero.vinschen.de
Date: Mon, 8 Aug 2016 16:33:21 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: PATHEXT is fundamental to Windows and Should be recognised by CYGWIN
Message-ID: <20160808143321.GS25811@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-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>
MIME-Version: 1.0
In-Reply-To: <e90174df-61b4-17c8-064b-30009e6ad559@gmail.com>
User-Agent: Mutt/1.6.2 (2016-07-01)

--YttKMwf6abDJOSyE
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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.
> >=20
> > 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".
> >=20
>=20
> Which is the exact cause of the issue.
>=20
> > In the POSIX realm, "foo" =3D=3D "foo.exe" =3D=3D "foo.lnk".  The searc=
h 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.
>=20
> 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 =3D=3D 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.
>=20
> As for PATHEXT we can do the following scenario instead.
>=20
> export PATHEXT=3D"$PATHEXT;.TXT"
> vi foo.txt
> :set ff=3Ddos
> 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.

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.


Corinna

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

--YttKMwf6abDJOSyE
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJXqJgwAAoJEPU2Bp2uRE+ggpoP/iCtAAFLpakXN+rLtjafpW0U
o9px45qeRHvgIMRiglHiHgx/trNVSrJtAVDSVJPz3KkJrk9COKcf2+RHrlomtE38
CTkWMQa8mFj1MoXg1GjwIskmITJlG+x9Ccbq5PF3KWD/WWUEZ/qovgIJHCL8KSHC
sne+MdcJVqfOIUOOcpI2Mos2OK9PexV4q2mJ63+E/NTE1MFLURdB3BfQt7Xtia8j
1+UQn8/SJmCQ8u4u9pU5AP9Q97zxvgfLxzmU6S18iY6iZVh5gYV5L9bslOlcbqBI
zZmCZbbN5aCLuU38wohb3cTX8xVtFXBFHxNIELsOeePunx6/xH2Y07I+EWPzsBrp
3968udiv92+dUOGhZ18IVaF/rM0iSp9r9eFzDpHrjXxg9rr+Wq67wK1rWSjyOSjy
53NpvivQrosSK75D49ssu9qaVJWqw7cXaBI/TXNcRxZf/5USe2MZhmJtWbxsF7cV
OMVDQ6yLm3rp2guv196LiYqzYYvQQUXyqLjBJjT3BOOXzptve35y6RMa4qEHJklT
vdEaxqKYPLwm82mxhXwg60WieBPkBu//5DJb6ZJifKCdElcxEts4qhxCf4oi817B
fPCQaAXFTmF4JsKbBzrqzCH+C6gd2Re9SRXL3j94TM+xRruVprPxOeqzhKNbj6k+
432k4SXQ2nrBSjDZN1IU
=hk3g
-----END PGP SIGNATURE-----

--YttKMwf6abDJOSyE--

- Raw text -


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