--- src/emacs.c.orig 2023-08-05 02:18:11.000000000 -0500 +++ src/emacs.c 2024-04-10 21:18:14.000000000 -0500 @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -1407,6 +1408,25 @@ #if defined DARWIN_OS && defined HAVE_UNEXEC if (!initialized) unexec_init_emacs_zone (); + + /* Imaxima won't work properly if PATH does not contain the + MacPorts directory. The following code is a workaround to + avoid this problem. */ + { + char *oldpath = getenv("PATH"); + if (!oldpath) {oldpath = "";} + size_t oldpathsize = strlen(oldpath) + 1; + if (!strstr(oldpath, "__PREFIX__/bin")) { + char *newpath; + size_t newpathsize = oldpathsize + strlen("__PREFIX__/bin:"); + if ((newpath = (char *)malloc(newpathsize)) != NULL) { + strlcpy(newpath, "__PREFIX__/bin:", newpathsize); + strlcat(newpath, oldpath, newpathsize); + setenv("PATH", newpath, 1); + free(newpath); + } + } + } #endif init_standard_fds ();