Mail Archives: djgpp-workers/2000/05/23/20:10:34
> The comments in dosexec.c say that this is the way it does work, but in this
> narrow case it does seem wrong.
>
This change works for me. It still lets 'foo' match with 'foo.exe', but doesn't let
'foo' match with 'foo.sh'.
*** src/libc/dos/process/dosexec.c.orig Tue Jun 29 11:50:10 1999
--- src/libc/dos/process/dosexec.c Tue May 23 20:07:42 2000
*************** static struct {
*** 914,919 ****
--- 914,925 ----
which is called when the program filename has no extension. */
#define INTERP_NO_EXT (sizeof(interpreters)/sizeof(interpreters[0]) - 3)
+
+ /* Index to stop trying to add extensions. Just as 'foo' will match
+ 'foo.exe' to emulate DOS shells, 'foo' will not match 'foo.sh'
+ to emulate Unix shells. */
+ static const int ext_append_stop = 4;
+
/*-------------------------------------------------*/
char *
*************** __dosexec_find_on_path(const char *progr
*** 946,952 ****
/* Under LFN, we must try the extensions even if PROGRAM already has one. */
if (!hasdot || _use_lfn(program))
! for (i=0; interpreters[i].extension; i++)
{
strcpy(rp, interpreters[i].extension);
if (access(buf, 0) == 0 && access(buf, D_OK))
--- 952,958 ----
/* Under LFN, we must try the extensions even if PROGRAM already has one. */
if (!hasdot || _use_lfn(program))
! for (i=0; i < ext_append_stop; i++)
{
strcpy(rp, interpreters[i].extension);
if (access(buf, 0) == 0 && access(buf, D_OK))
*************** __dosexec_find_on_path(const char *progr
*** 999,1005 ****
*rp = 0;
if (!hasdot || _use_lfn(buf))
! for (i=0; interpreters[i].extension; i++)
{
strcpy(rp, interpreters[i].extension);
if (access(buf, 0) == 0 && access(buf, D_OK))
--- 1005,1011 ----
*rp = 0;
if (!hasdot || _use_lfn(buf))
! for (i=0; i < ext_append_stop; i++)
{
strcpy(rp, interpreters[i].extension);
if (access(buf, 0) == 0 && access(buf, D_OK))
*************** int __spawnve(int mode, const char *path
*** 1059,1065 ****
If so, look for RPATH.ext before even trying RPATH itself. */
if (_use_lfn(rpath) || !rd)
{
! for (i=0; interpreters[i].extension; i++)
{
strcpy(rp, interpreters[i].extension);
if (access(rpath, F_OK) == 0 && !(is_dir = (access(rpath, D_OK) == 0)))
--- 1065,1071 ----
If so, look for RPATH.ext before even trying RPATH itself. */
if (_use_lfn(rpath) || !rd)
{
! for (i=0; i < ext_append_stop; i++)
{
strcpy(rp, interpreters[i].extension);
if (access(rpath, F_OK) == 0 && !(is_dir = (access(rpath, D_OK) == 0)))
*************** int __spawnve(int mode, const char *path
*** 1084,1089 ****
--- 1090,1096 ----
i = INTERP_NO_EXT;
rpath_ext = "";
}
+ *rp = 0;
for ( ; interpreters[i].extension; i++)
if (stricmp(rpath_ext, interpreters[i].extension) == 0
&& access(rpath, F_OK) == 0
- Raw text -