delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/07/05/07:34:41

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
X-Envelope-Sender-Is: Andrej DOT Borsenkow AT mow DOT siemens DOT ru (at relayer goliath.siemens.de)
From: "Andrej Borsenkow" <Andrej DOT Borsenkow AT mow DOT siemens DOT ru>
To: <cygwin AT cygwin DOT com>, "Michael Schaap" <cygwin AT mscha DOT com>
Cc: "ZSH Workers Mailing List" <zsh-workers AT sunsite DOT dk>
Subject: RE: Zsh observations
Date: Thu, 5 Jul 2001 15:33:26 +0400
Message-ID: <000501c10546$4e7318e0$21c9ca95@mow.siemens.ru>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
In-Reply-To: <5.1.0.14.2.20010705112435.03520c60@imap.mscha.org>
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2479.0006

>
> At 07:59 5-7-2001, Andrej Borsenkow wrote:
> >Zsh relies on system execve to find command. Basically, it does
> >
> >for dir in path
> >   execve dir/cmd
> >
> >until it succeeds. We recently have a brief discussion on
> zsh-workers about
> >it. Irrespectivley if you consider it a bug or feature this was
> around for a
> >very long time. So the above lets suspect problem in Cygwin exec
> - sometimes
> >it fails to execute /a/hello.exe. Can you reliably reproduce it?
>
> Yes, I've figured it out.
> It only happens when "setopt correct" is set, the first instance
> of a file
> in the PATH has a .exe extension, and the second doesn't.  Here's how to
> reproduce it.
>
> I created an executable /tmp/a/dummy.exe which prints "a", and a script
> "/tmp/b/dummy" which prints "b".
>
> Move all zsh initialisation files (/etc/z* and ~/.z*) away, and
> open a new
> zsh window.
>

You do not need it. Just do zsh -f. The only file that will be sourced (if
exists) is /etc/zshenv.

> Now type:
>          % PATH=/usr/bin:/tmp/a:/tmp/b
>          % dummy
>          a
>
> Open a new zsh window, and type:
>          % PATH=/usr/bin:/tmp/a:/tmp/b
>          % setopt correct
>          % dummy
>          b
>
> Conclusion: don't use "setopt correct" under Cygwin. :-(
>

Apply this patch and do it :-) It was lost when gcc stopped setting _WIN32
by default.

Note, that it will make completion list executables twice - as foo and
foo.exe. With new completion you may want to set something like

zstyle ':completion::complete:-command-:*' ignored-patterns
'*.(#i)(exe|dll)'

to prevent *.exe and *.dll from appearing in the list (given, that every
foo.exe is already hashed as foo, it is O.K.; and dll is not executable
anyway - or is it?)

With old completion you may set fignore parameter.

cheers

-andrej

Index: Src/hashtable.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hashtable.c,v
retrieving revision 1.10
diff -u -r1.10 hashtable.c
--- Src/hashtable.c     2001/05/19 09:22:07     1.10
+++ Src/hashtable.c     2001/07/05 11:27:21
@@ -630,9 +630,9 @@
     Cmdnam cn;
     DIR *dir;
     char *fn;
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
     char *exe;
-#endif
+#endif /* _WIN32 || _CYGWIN__ */

     if (isrelative(*dirp) || !(dir = opendir(unmeta(*dirp))))
        return;
@@ -644,7 +644,7 @@
            cn->u.name = dirp;
            cmdnamtab->addnode(cmdnamtab, ztrdup(fn), cn);
        }
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
        /* Hash foo.exe as foo, since when no real foo exists, foo.exe
           will get executed by DOS automatically.  This quiets
           spurious corrections when CORRECT or CORRECT_ALL is set. */
@@ -660,7 +660,7 @@
                cmdnamtab->addnode(cmdnamtab, ztrdup(fn), cn);
            }
        }
-#endif /* _WIN32 */
+#endif /* _WIN32 || __CYGWIN__ */
     }
     closedir(dir);
 }


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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