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]);
}
This is just bad:
main(string[] args) calls init(args) that calls findGDC(args[0])
that gives auto gdcDir = absolutePath(dirName(argv0));
Which is not good:
findGDC: argv0=gdmd
findGDC: dirName(argv0)=.
findGDC: gdcDir=/home/user/github/gdmd/.
That is: it will look for gdc in the current folder, which is not
even the base folder of gdmd (eg. /usr/bin), but the working
directory.
In other words, it looks for gdc in the current working folder.
Then it complains:
Not an executable file: /home/user/github/gdmd/gdc
which is understandable.
I think it should simply look on the PATH.