--- mojosetup-original/platform_unix.c 2009-06-04 19:03:32.000000000 +0200 +++ mojosetup-2-whitespace/platform_unix.c 2009-06-05 03:16:13.000000000 +0200 @@ -1125,6 +1125,11 @@ static boolean unix_launchXdgUtil(const { boolean retval = false; char *path = findBinaryInPath(util); + char *install_path = NULL; + char *working_dir = NULL; + + if ((working_dir = MojoPlatform_currentWorkingDir()) == NULL) + return false; if (path != NULL) // it's installed on the system; use that. { @@ -1133,25 +1138,61 @@ static boolean unix_launchXdgUtil(const int i; for (i = 0; argv[i]; i++) { - char *escaped = shellEscape(argv[i]); + char *escaped = NULL; + if(strchr(argv[i], '/') != NULL ) + { + install_path = xstrdup(argv[i]); + char *t = strrchr(argv[i], '/'); + escaped = shellEscape(t+1); + } // if + else + escaped = shellEscape(argv[i]); + tmp = format("%0 %1", cmd, escaped); free(escaped); free(cmd); cmd = tmp; } // for + char install_dir[strlen(install_path)+1]; + xstrncpy(install_dir, install_path, strrchr(install_path, '/')-install_path+1); tmp = format("%0/%1 >/dev/null 2>&1", path, cmd); free(cmd); cmd = tmp; + if( chdir(install_dir) != 0) + return false; + retval = (system(cmd) == 0); free(cmd); + chdir(working_dir); } // if - else // try our fallback copy of xdg-utils in GBaseArchive? + else // try our fallback copy of xdg-utils in GBaseArchive? { char *script = format("meta/xdg-utils/%0", util); - retval = (runScript(script, true, argv) == 0); + int i, argc = -1; + const char **clean_argv = NULL; + + while(argv[++argc] != NULL){} + clean_argv = (const char **) xmalloc(sizeof (char *) * argc); + + for(i=0; i < argc; i++) + { + if(strchr(argv[i], '/') != NULL) + { + install_path = xstrdup(argv[i]); + clean_argv[i] = strrchr(argv[i], '/')+1; + } + else + clean_argv[i] = argv[i]; + } // for + + char install_dir[strlen(install_path)+1]; + xstrncpy(install_dir, install_path, strrchr(install_path, '/')-install_path+1); + chdir(install_dir); + retval = (runScript(script, true, clean_argv) == 0); free(script); + chdir(working_dir); } // if return retval;