- Fix cmd's SearchForExecutable: it was inside out, giving extension priority over directory.

- Remove code that checked if the file's extension was in PATHEXT. Windows does not check, and it's very handy to be able to "run" non-executable files.
- Allow explicit paths with no backslash (like "A:file")
- Batch: use GetFullPathName to get the batch file's absolute path; this way %~dp0 will always give the right directory even in the weird case of running the .bat via a relative path in PATH. Remove code in SearchForExecutable which tried to make sure it returned an absolute path (but it didn't in that case).

svn path=/trunk/; revision=35187
This commit is contained in:
Jeffrey Morlan 2008-08-08 16:48:21 +00:00
parent fbb7095a67
commit b75ff606ba
2 changed files with 54 additions and 107 deletions

View file

@ -263,10 +263,10 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
cmd_free (bc->raw_params);
}
ZeroMemory(bc->BatchFilePath, sizeof(bc->BatchFilePath));
GetFullPathName(fullname, sizeof(bc->BatchFilePath), bc->BatchFilePath, &tmp);
*tmp = '\0';
bc->hBatchFile = hFile;
tmp = _tcsrchr(fullname, '\\');
_tcsncpy(bc->BatchFilePath, fullname, ((_tcslen(fullname) - _tcslen(tmp)) + 1));
SetFilePointer (bc->hBatchFile, 0, NULL, FILE_BEGIN);
bc->bEcho = bEcho; /* Preserve echo across batch calls */
bc->shiftlevel = 0;