This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Directory existence prevents .exe execution

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.


Larry Hall                    
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:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]