<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
I don't believe that FS.GetAbsolutePathname(RTArgs.Get(1)) is correct.<BR>
<BR>
mkdir /path /cwd<BR>
PATH=/path<BR>
cp /usr/bin/ls /path<BR>
cp /usr/bin/ls /cwd<BR>
cd /cwd<BR>
ls<BR>
<BR>
<BR>
You will return /cwd/ instead of the correct /path/lsh.<BR>
The code I have seen to handle this is roundabout.<BR>
You have to first check for dots and/or slashes. If they are present, you use GetAbsolutePathname like you do.<BR>
Else you split up $PATH on the appropriate character, appending argv[0] to each element and see if it exists and/or is executable.<BR>
On Windows that isn't right probably, due to "extensions", however on Windows there is a very simple way, just GetModuleFileName(NULL).<BR>
I expect there is a simple way on Mac too.<BR>
There might be a way to fish out the dynamic linker parameters on other systems. But I don't think Posix provides a correct simple way.<BR>
<BR>
- Jay<BR><BR> <BR>> Date: Wed, 23 Sep 2009 13:53:49 -0500<BR>> From: rodney.m.bates@cox.net<BR>> To: m3devel@elegosoft.com<BR>> Subject: Re: [M3devel] Reasoning for /usr/local/cm3 ?<BR>> <BR>> I've had this around for a while. Don't know how portable it is.<BR>> It's mainly a main executable wrapper for, and<BR>> delegates the real work to, FS.GetAbsolutePathname,<BR>> which, if not fully portable, ought to be fixed so it is. <BR>> <BR>> It works on LINUXLIBC6 and AMD64_LINUX. <BR>> <BR>> It also changes backslashes to forward slashes.<BR>> Maybe better for general script use if it returned<BR>> a return code if things go awry. <BR>> <BR>> jay.krell@cornell.edu wrote:<BR>> > Upon further thought symlink might not work. We can make it work on <BR>> > some systems e.g. Mac and cygwin. Problem I see is, how does one find <BR>> > the executable's fullpath? If the symlink source is in argv[0] then no <BR>> > posix portable way. I was looking at this for finding cm3.cfg.<BR>> ><BR>> > -jay/phone<BR>> ><BR>> <BR> </body>
</html>