delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/04/18/00:42:54

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <480826A5.8070602@cygwin.com>
Date: Fri, 18 Apr 2008 00:42:13 -0400
From: "Larry Hall (Cygwin)" <reply-to-list-only-lh AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20070505 Remi/2.0.0.0-3.fc4.remi Lightning/0.8 Thunderbird/2.0.0.0 Mnenhy/0.7.5.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Directory existence prevents .exe execution
References: <D80722838B6A6B4BA3CA9D90BA70BBB302E0DFAF AT dhrseasvxb04 DOT messaging DOT danaherad DOT com> <20080416064211 DOT 40A7F84237 AT pessard DOT research DOT canon DOT com DOT au> <f60fe000804160213r5adcaff3pd860d22494a0a24a AT mail DOT gmail DOT com> <48080FC4 DOT 4090108 AT cisra DOT canon DOT com DOT au> <48081622 DOT 5030405 AT cygwin DOT com> <48081EAB DOT 10808 AT cisra DOT canon DOT com DOT au>
In-Reply-To: <48081EAB.10808@cisra.canon.com.au>
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

On 04/18/2008, Luke Kendall wrote:
> Larry Hall (Cygwin) wrote: What do you mean by Cygwin, in this case?
> Bash?  Cygwin's implementation of exec()?

In this case, bash.  Try it from, say, csh, and you'll see something a
bit different.

>> It uses stat() to find out what type of thing "foo" is.  Then it uses
>> that information to decide how to handle "foo".
>> 
> This is why I'm saying that something that handles the invocation of 
> programs under Cygwin tries to execute directories:
> 
> $ /opt/bin/ici -help bash: /opt/bin/ici: is a directory $ whiches ici 
> /opt/bin/ici.exe /opt/bin/ici.dll /cygdrive/x/bin/ici.exe 
> /cygdrive/x/bin/ici.dll $ ls -ld /opt/bin/Ici drwxr-xr-x 1 luke Domain
> Users 0 Oct 17  2005 /opt/bin/Ici
> 
> It looks like something has stat()ed /opt/bin/ici and then decided it's 
> been asked to execute that, and refusing (which makes a kind of sense),
> and bailing out with an error (*that* step seems wrong to me).

Well, didn't you ask to execute '/opt/bin/ici'?  After all, that's what you
typed.  I don't see how it could be wrong to report back what you asked to
execute is a directory.

> I assumed that the logic which invokes foo.exe when you type foo should 
> not be trying to execute a directory called foo.  It's never right to 
> try to execute a directory.

True enough.  Hence the message.  The directory isn't being executed here.

> I'm suggesting that instead of trying to do that and reporting an error 
> and failing, the code should just skip past that as obviously wrong and 
> fall through to the rest of its logic, which would in fact do the right 
> thing - even if the foo.exe was in some other directory entirely, later 
> on the PATH!

If you ask for 'foo' or '/path/to/foo' and that's a directory, going beyond
that looking for something else when you've found an exact match is a bit
dangerous.  You don't want to be taking too many liberties with the exe
magic.  Things could get ugly fast.  That said, if you want an executable
to be named "foo" and not "foo.exe", you can do that on NT-based platforms.
But again, here you're back to a situation where you won't be able to have
a same-named directory right beside the executable.  But that matches *nix.


-- 
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
216 Dalton Rd.                          (508) 893-9889 - FAX
Holliston, MA 01746

_____________________________________________________________________

A: Yes.
> Q: Are you sure?
>> A: Because it reverses the logical flow of conversation.
>>> Q: Why is top posting annoying in email?

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

- Raw text -


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