This is the mail archive of the cygwin-patches 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: [Patch] "strace ./app.exe" probably runs application from /bin


Brian Dessent wrote:
Christopher Faylor wrote:

Let me rephrase the problem:

"cygpath does not properly deal with the current directory"

Thanks for the patch but we won't be applying it in this form.

I've been meaning to take a look at fixing this myself, because I'm tired of:

$ cd /usr/bin

$ cygcheck ./ls
.\.\.\.\ - Cannot open

$ cygcheck ls
 - Cannot open
Error: could not find ls

$ cygcheck ls.exe
 - Cannot open
Error: could not find ls.exe

$ cygcheck ./ls.exe
.\ls.exe
  .\cygwin1.dll
    C:\WINXP\system32\ADVAPI32.DLL
      C:\WINXP\system32\ntdll.dll
      C:\WINXP\system32\KERNEL32.dll
      C:\WINXP\system32\RPCRT4.dll
  .\cygintl-8.dll
    .\cygiconv-2.dll


This is a different and subtle issue in cygcheck itself:


The init_path() routine adds cwd first.
add_path() does not add duplicate path names later.
If cwd is C:\cygwin\bin, it only appears in the sysdirs part of the path.

find_on_path(.,.,.,0) does never check a PATH component equal to cwd.

The attached patch is a quick hack (again, sorry ;-) to fix this.

Christian

--- cygwin-1.5.24-2.orig/winsup/utils/cygcheck.cc	2006-02-08 15:19:40.001000000 +0100
+++ cygwin-1.5.24-2/winsup/utils/cygcheck.cc	2007-06-03 17:55:04.406250000 +0200
@@ -196,7 +196,7 @@ add_path (char *s, int maxlen)
   char *e = paths[num_paths] + strlen (paths[num_paths]);
   if (e[-1] == '\\' && e[-2] != ':')
     *--e = 0;
-  for (int i = 1; i < num_paths; i++)
+  for (int i = 2; i < num_paths; i++)
     if (strcasecmp (paths[num_paths], paths[i]) == 0)
       {
 	free (paths[num_paths]);

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