On 10 July 2013 13:14, eles <e...@eles.com> wrote: > On Wednesday, 10 July 2013 at 12:03:06 UTC, eles wrote: >> >> On Wednesday, 10 July 2013 at 10:24:17 UTC, Joseph Rushton Wakeling wrote: >>> >>> On 07/10/2013 02:07 AM, H. S. Teoh wrote: >>>> >>>> Comments / flames / pull requests welcome. ;-) >>> >>> >>> string findGDC(string argv0) >>> { >>> // FIXME: this does not work 100% of the time. >>> auto c = match(baseName(argv0), `^(.*-)?g?dmd(-.*)?$`).captures; >>> auto targetPrefix = c[1]; >>> auto gdcDir = absolutePath(dirName(argv0)); >>> return buildNormalizedPath(gdcDir, targetPrefix ~ "gdc" ~ c[2]); >>> } > > > Quick and unportable (Linux-only) drop-in replacement: >
Christ on a bike. What's wrong with: import std.file; import std.process : environment; auto binpaths = environment.get("PATH"); foreach (path; binpaths.split(<delimiter>) { auto exe = path ~ <dirsep> ~ "gdc"; if (exists (exe)) { // found } } -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';