The attached patch allows executing a path in backslash notation.  This can be 
tested in the Cygwin builds of GNU make with the "DOS compatibility" 
compile-time option of GNU make enabled, such as those from Cygwin make 
packages 3.79 and 3.80.

$ cat dos-compat.mak
default:
        ..\echo.exe test
        C:\<FULLPATH>\echo.exe test

$ ./make.exe --win32 -f dos-compat.mak
..\echo.exe test
test
C:\<FULLPATH>\echo.exe test
test

The patch cannot be tested by simply running a command in backslash notation in 
the existing Cygwin build of bash or pdksh because these shells re-implement 
the search of the potential executable command.  I believe these 
re-implementations are for improved user interaction and platform-independent 
security.

The patch is a blind conjecture because I am not fully aware about the 
intention of find_exec() in spawn.cc.  Its implementation seems exceedingly 
complicated to me, and the comments in the middle of the function about 
refusing a full Windows path contradict the description of the function above 
its prototype.

-- 
Index: spawn.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/spawn.cc,v
retrieving revision 1.288
diff -u -r1.288 spawn.cc
--- spawn.cc    25 Jan 2010 11:21:56 -0000      1.288
+++ spawn.cc    9 Mar 2010 00:20:54 -0000
@@ -112,15 +112,16 @@
   char *tmp = tp.c_get ();
   const char *posix = (opt & FE_NATIVE) ? NULL : name;
   bool has_slash = strchr (name, '/');
+  bool has_backslash = strchr (name, '\\');
   int err;
 
   /* Check to see if file can be opened as is first.
      Win32 systems always check . first, but PATH may not be set up to
      do this. */
-  if ((has_slash || opt & FE_CWD)
+  if ((has_slash || has_backslash || opt & FE_CWD)
       && (suffix = perhaps_suffix (name, buf, err, opt)) != NULL)
     {
-      if (posix && !has_slash)
+      if (posix && !has_slash && !has_backslash)
        {
          tmp[0] = '.';
          tmp[1] = '/';
@@ -147,7 +148,7 @@
       path = s;
       posix_path = mywinenv - 1;
     }
-  else if (has_slash || strchr (name, '\\') || isdrive (name)
+  else if (has_slash || has_backslash || isdrive (name)
       || !(winpath = getwinenv (mywinenv))
       || !(path = winpath->get_native ()) || *path == '\0')
     /* Return the error condition if this is an absolute path or if there
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply via email to