Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: Zsh observations
- X-seq: zsh-workers 15253
- From: "Andrej Borsenkow" <Andrej.Borsenkow@xxxxxxxxxxxxxx>
- To: <cygwin@xxxxxxxxxx>, "Michael Schaap" <cygwin@xxxxxxxxx>
- Subject: RE: Zsh observations
- Date: Thu, 5 Jul 2001 15:33:26 +0400
- Cc: "ZSH Workers Mailing List" <zsh-workers@xxxxxxxxxx>
- Importance: Normal
- In-reply-to: <5.1.0.14.2.20010705112435.03520c60@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
>
> 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);
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author