Update of /cvsroot/winbash/winbash
In directory usw-pr-cvs1:/tmp/cvs-serv6744
Modified Files:
nt_execute_cmd.c
Log Message:
Applied Kevin's bug fix to properly deal with directories when trying to execute a file
Index: nt_execute_cmd.c
===================================================================
RCS file: /cvsroot/winbash/winbash/nt_execute_cmd.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- nt_execute_cmd.c 10 Mar 2002 21:45:13 -0000 1.2
+++ nt_execute_cmd.c 14 Mar 2002 22:09:54 -0000 1.3
@@ -1092,13 +1092,24 @@
if ((orig_status & reg_exe) == reg_exe)
return orig_status;
- /* If the file is a directory, then it is not "executable" in the
- sense of the shell. */
- if(stat (*name, &finfo) >= 0 && S_ISDIR (finfo.st_mode))
- return orig_status;
+ /* look for 'name.{exe,com,sh,pl,bat,...}' first before
+ * checking to see if 'name' is a directory. otherwise, if
+ * the actual executable and a directory of the same name
+ * exist in the same directory, the actual exe will not be
+ * resolved. for example, suppose the following structure:
+ * c:/bin/
+ * CVS/
+ * cvs.exe
+ * and suppose PATH="c:/bin". if the command 'cvs' is run,
+ * the CVS directory would be found first, and the command
+ * would fail. unfortunately, this is a little slower, but
+ * correctness is more important than speed.
+ *
+ * kevin seguin, 03.03.2002
+ */
while (try = try_names (nm))
- {
+ {
int status = file_status (try);
nm = 0;
if ((status & reg_exe) == reg_exe)
@@ -1109,7 +1120,11 @@
*name = ret;
return status;
}
- }
+ }
+ /* If the file is a directory, then it is not "executable" in the
+ sense of the shell. */
+ if(stat (*name, &finfo) >= 0 && S_ISDIR (finfo.st_mode))
+ return orig_status;
return orig_status;
}
|