Directory existence prevents .exe execution

Igor Peshansky pechtcha@cs.nyu.edu
Thu Apr 17 15:25:00 GMT 2008


On Wed, 16 Apr 2008, Luke Kendall wrote:

> We have the Ici scripting language installed on Windows.  Ici expects a
> directory called "ici" to exist alongside, where various libraries are
> installedd to provide extra functionality.
>
> Unfortunately, under Cygwin, if w try to run the command "ici" we get
> the error "ici: command not found", because Cygwin chooses to try to
> execute the directory instead of the .exe:

This behavior (preferring the unadorned file name to the .exe) has been in
existence for a while (at least a year).  We relied on the old behavior by
having a script and a .exe with the same name (and expecting the .exe to
be invoked on Windows/Cygwin).  I remember we've had to work around this
issue when the change happened, by prepending the following to our script:

[ -x "$0.exe" ] && exec "$0.exe" "$@"

> $ /opt/bin/ici /cygdrive/x/bin/script/cfnhdr
> bash: /opt/bin/ici: is a directory
> $ ls -ld /opt/bin/ici
> drwxr-xr-x 1 luke Domain Users 0 Oct 17  2005 /opt/bin/ici
> $ ls -ld /opt/bin/ici.*
> -rwxr-xr-x 1 luke Domain Users 233503 Apr 18  2000 /opt/bin/ici.dll
> -rwxr-xr-x 1 luke Domain Users  24576 Jan 29  2003 /opt/bin/ici.exe
>
> I tried naming the ici directory Ici but it made no difference.

Try also CYGWIN="$CYGWIN check_case:strict" (while the code is still in
the DLL) or managed mounts...  The latter won't work unless ici.exe is a
Cygwin program.

> The directory /opt/bin is mounted like so:
> $ mount
> \\samba\syncopt\microsoft.x86.win\bin on /opt/bin type system (textmode,exec)
>
> Using binmode doesn't help.  Is this a bug, that bash tries to execute a
> directory even when there's an executable (with an implicit .exe suffix,
> naturally) of the same name in existence ?

No, this is expected behavior (if you search through bash release
announcements, you should be able to see the exact point at which the
change happened).

> If not, can anyone suggest a workaround?

Other than renaming the directory or using a wrapper script, no.

> I can't just append a .exe to the #!/opt/bin/ici shell wrapper since
> then the scripts wouldn't run from Unix.

How do these scripts *ever* run from Unix?  Unix would definitely not be
aware of the .exe suffix, and would always attempt to execute
/opt/bin/ici, which, as you say, is a directory.  Do you have a
/opt/bin/ici script as well?

In any case, whatever solution you use to make it work from Unix should
work on Cygwin as well.

> Is there a bash option that controls this, maybe (I couldn't see one)?

There is no bash option to control this, AFAIK.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha@cs.nyu.edu | igor@watson.ibm.com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"That which is hateful to you, do not do to your neighbor.  That is the whole
Torah; the rest is commentary.  Go and study it." -- Rabbi Hillel

--
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/



More information about the Cygwin mailing list