From: cgf AT bbc DOT com (Christopher Faylor) Subject: Re: cygwinb19.1.dll sh.exe still won't run shell scripts from path + workaround 19 Mar 1998 21:11:12 -0800 Message-ID: <199803191336.IAA00670.cygnus.cygwin32.developers@hardy.bbc.com> To: jeffdb AT netzone DOT com Cc: cygwin32-developers AT cygnus DOT com 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?