@@ -7,16 +7,20 @@ string findExecutable(string executableName)
77 import std.path : isAbsolute, extension, buildPath;
88 import std.file ;
99 import std.algorithm.iteration :splitter;
10+
11+ if (executableName.length == 0 )
12+ throw new Exception (" Needs an executable name to find." );
1013 string pathEnv = getEnvVariable(" PATH" );
1114
1215 version (Windows )
13- static string [] EXTENSIONS = [" .exe" , " .bat" , " .cmd" , " .com" , " " ];
16+ static immutable string [] EXTENSIONS = [" .exe" , " .bat" , " .cmd" , " .com" , " " ];
1417 else
15- static string [] EXTENSIONS = [" " ];
18+ static immutable string [] EXTENSIONS = [" " ];
19+ static immutable string [] emptyExt = [" " ];
1620
17- string [] extensionsTest = EXTENSIONS ;
21+ const ( string ) [] extensionsTest = EXTENSIONS ;
1822 if (extension(executableName) != null )
19- extensionsTest = [ " " ] ;
23+ extensionsTest = emptyExt ;
2024
2125 static bool isExecutable (string tPath)
2226 {
@@ -44,7 +48,7 @@ string findExecutable(string executableName)
4448 foreach (path; splitter (pathEnv, pathSeparator))
4549 {
4650 string str = redub.misc.path.normalizePath(bufferSink, path, executableName);
47- foreach (ext; EXTENSIONS )
51+ foreach (ext; extensionsTest )
4852 {
4953 bufferSink[str.length.. str.length+ ext.length] = ext;
5054 string fullPath = cast (string )buffer[0 .. str.length+ ext.length];
0 commit comments