> (Which in itself tickles and scares the bejesus out of me.) Is there a > good way of finding the standard C library on a Unix system other than > hard-wiring it in like this? Yes. Parrot is linked with the standard C library. You can get a handle for the own executable by passing a NULL pointer to dlopen. You can also use this handle to call libc functions. You can not pass a NULL pointer to loadlib at the moment, this small hacks "converts" an empty string to a NULL pointer to pass it to Parror_dlopen:
const char * s = 0;
if( $2->strlen != 0 ) { s = string_to_cstring(interpreter, ($2)); } p = Parrot_dlopen(s);
With this hack, the following code will work:
loadlib P1, "" dlfunc P0, P1, "system", "it" set I0, 1 set S5, "ls" invoke end
A very cool hack, indeed. :)
It's gonna need a little work though. On Win32 Parrot_dlopen is a passthrough to LoadLibrary() which, as far as I can tell, doesn't have the same behavior for this case. *But* it seems as though if you can find parrot's name (imcc.exe, parrot.exe, etc...) and pass *that* to loadlib it should work fine. Maybe. More testing required.
On my linux box (which was the issue...) it seems fine though. Whee.
Thanks!