X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: <48082B57.7050705@cisra.canon.com.au> Date: Fri, 18 Apr 2008 15:02:15 +1000 From: Luke Kendall <luke DOT kendall AT cisra DOT canon DOT com DOT au> User-Agent: Thunderbird 1.5.0.14 (Windows/20071210) 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> <480826A5 DOT 8070602 AT cygwin DOT com> In-Reply-To: <480826A5.8070602@cygwin.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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 Larry Hall (Cygwin) wrote: > 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. > $ /opt/bin/ici -help CORRECT>/opt/bin/Ici -help (y|n|e|a)? no /opt/bin/ici: Command not found. $ /opt/bin/ici -help CORRECT>/opt/bin/Ici -help (y|n|e|a)? yes /opt/bin/Ici: Permission denied. Yep, it's no better. It even specifically offers me the optio to try to execute the directory. >>> 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 thought that bash treated the first word on the line (after optional assignments to environment variables a la FRED=x run-some-command) as a command to execute, passing the remaining words on the line to the command as arguments? (Leaving aside things like backtic execution and variable expansion.) So I still think I asked for /opt/bin/ici to be executed by bash. I'd be interested to know if I've misunderstood. I also checked that bash doesn't work this way under Linux. I created a directory called ici (with execute permission, obviously), in the first directory in my PATH. I then ran ici from bash, and it did not tell me that ici was a directory and bail out - it executed the first ici executable it found later in my PATH. That's all I was hoping that Cygwin's bash would do, too. zsh under Cywgin is worse, though: $ /opt/bin/ici -help zsh: no such file or directory: /opt/bin/ici >> 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. > > -- 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/