From: Junio C Hamano Date: Mon, 30 Jan 2017 17:03:11 GMT Subject: Re: [PATCH v2] help: improve is_executable() on Windows Message-ID: In-Reply-To: <4b93fe44ff9020ed80e4fd93a24a6ffa647e7678.1485780050.git.johannes.schindelin@gmx.de> Johannes Schindelin writes: > From: Heiko Voigt > > On Windows, executables need to have the file extension `.exe`, or they > are not executables. Hence, to support scripts, Git for Windows also > looks for a she-bang line by opening the file in question, and executing > it via the specified script interpreter. > > To figure out whether files in the `PATH` are executable, `git help` has > code that imitates this behavior. With one exception: it *always* opens > the files and looks for a she-bang line *or* an `MZ` tell-tale > (nevermind that files with the magic `MZ` but without file extension > `.exe` would still not be executable). > > Opening this many files leads to performance problems that are even more > serious when a virus scanner is running. Therefore, let's change the > code to look for the file extension `.exe` early, and avoid opening the > file altogether if we already know that it is executable. Much more readable than the initial round. Will queue; thanks.