X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: <480833E8.1030609@cygwin.com> Date: Fri, 18 Apr 2008 01:38:48 -0400 From: "Larry Hall (Cygwin)" 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: <20080416064211 DOT 40A7F84237 AT pessard DOT research DOT canon DOT com DOT au> <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> <48082B57 DOT 7050705 AT cisra DOT canon DOT com DOT au> In-Reply-To: <48082B57.7050705@cisra.canon.com.au> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 Luke Kendall wrote: > Larry Hall (Cygwin) wrote: >> On 04/18/2008, Luke Kendall wrote: >>> 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 think you did as well. And so does bash. But it's not going to allow you to execute a directory, which is what your invocation matches exactly. So it tells you that you made a mistake by trying to execute a directory. I guess we're in violent agreement that you got what you asked for. > 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. Well here you're not comparing the same thing at all. You can't put a file/binary named "ici" in the same spot as a directory you have named "ici". So you've already changed the rules. But try the exact same thing you just did under Linux on Cygwin and you'll see the same behavior as Linux. The point is that Windows allows you to do something you can't do in Linux. You can have the name of an executable match the name of a directory, if you ignore the extension. In addition you can run an executable by only providing part of its name (i.e. not the extension). You can't do this under Linux. And why would you want to. But if you try to put that same-named executable and directory under the one directory and then run the executable from there without providing the full name, you're being imprecise. Cygwin's bash lets you know this. You can't compare this behavior to Linux because you'd never get into that situation. Don't confuse any of this with an executable named "ici.exe" in one directory in your path and a directory named "ici" in another (also in your path). This isn't a general issue that will bite you every time you want to run "ici.exe" in this configuration. In this scenario, the only time running "ici.exe" as "ici" would cause you to get the complaint that "ici" is a directory is if you were trying to run it from the parent directory of "ici"-the-directory. And if you take that parent directory (and "." if you have that) out of your path, you can run "ici.exe" as "ici" from anywhere. Better? -- 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/