Mail Archives: cygwin-developers/1998/03/19/21:11:12
Looks good to me.
cgf
>--- fhandler.cc 1998/03/19 07:38:31 1.1
>+++ fhandler.cc 1998/03/19 07:13:33
>@@ -1086,6 +1086,25 @@
>
> res = this->fhandler_base::open (real_path.get_win32 (), flags, mode);
>
>+
>+ if ((get_os_type () != winNT) && (!real_path.exec_p))
>+ {
>+ DWORD done;
>+ char magic[2];
>+ /* FIXME should we use /etc/magic ? */
>+ magic[0] = magic[1] = magic[2] = '\0';
>+ ReadFile (get_handle (), magic, 3, &done, 0);
>+ if (magic[0] == ':' && magic[1] == '\n')
>+ real_path.exec_p = 1;
>+
>+ if (magic[0] == '#' && magic[1] == '!')
>+ real_path.exec_p = 1;
>+ if (flags & O_APPEND)
>+ SetFilePointer (get_handle(), 0, 0, FILE_END);
>+ else
>+ SetFilePointer (get_handle(), 0, 0, FILE_BEGIN);
>+ }
>+
> symlink_p_ = real_path.symlink_p;
> execable_p_ = real_path.exec_p;
>
>@@ -1255,9 +1274,9 @@
>
> if (strcasecmp (".bat", ch) == 0
> || strcasecmp (".exe", ch) == 0
>- || strcasecmp (".com", ch) == 0)
>+ || strcasecmp (".com", ch) == 0
>+ || strcasecmp (".shc", ch) == 0) /* file associate sh -c == ShellScript */
> return 1;
>-
> return 0;
> }
>
>
>This is fairly quick, I actually didn't notice any difference,
>and it seems to work correctly for both : and #! for ash.exe/sh.exe
>bash dosen't like :\n for some reason. bash bug?
- Raw text -