From: corinna DOT vinschen AT cityweb DOT de (Corinna Vinschen) Subject: Forgotten change 16 Sep 1998 14:29:35 -0700 Message-ID: <36002924.C74CF718.cygnus.cygwin32.developers@cityweb.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: cygwin32-developers AT cygnus DOT com I have forgotten the following patch to fhandler_disk_file::check_execable(), which is sure a point of discussion, but if working with tcsh, it's easier, to remove all .exe suffixes from the files. IMHO, the following patch, which checks the suffix '.sh' and moreover the first bytes in a file, slows down 'ls -l' only a little bit, but gives more info. Corinna ---------- snip ------------ *** fhandler.cc.orig Wed Sep 16 23:02:54 1998 --- fhandler.cc Wed Sep 16 23:02:57 1998 *************** fhandler_disk_file::check_execable_p (co *** 1277,1284 **** --- 1277,1303 ---- if (strcasematch (".bat", ch) || strcasematch (".exe", ch) || strcasematch (".com", ch) + || strcasecmp (".sh", ch + 1) == 0 || strcasematch (".shc", ch)) /* file associate sh -c == ShellScript */ return 1; + + #if 1 + /* We also can test the first bytes in the file. */ + { HANDLE fh; + char buf[4]; + + if ((fh = CreateFileA(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, + 0, 0)) != INVALID_HANDLE_VALUE) { + DWORD bytes_read; + ReadFile(fh, buf, 4, &bytes_read, 0); + CloseHandle(fh); + if (! memcmp(buf, "\x4d\x5a\x90\0", 4) || + ! memcmp(buf, "#!", 2)) + return 1; + } + } + #endif + return 0; }