Index: gimp-remote.c
===================================================================
RCS file: /cvs/gnome/gimp/tools/gimp-remote.c,v
retrieving revision 1.3
diff -u -r1.3 gimp-remote.c
--- gimp-remote.c	2000/08/08 14:05:50	1.3
+++ gimp-remote.c	2001/06/19 14:23:27
@@ -63,6 +63,7 @@
 
 #include "config.h"
 
+#include <string.h>
 #include <errno.h>
 #include <unistd.h>
 
@@ -179,10 +180,22 @@
 
 static void
 start_new_gimp (GString *file_list)
-{     
-  gint    i;
+{
+  gchar  *path;
+  gchar  *end;
   gchar **argv;
-  
+  gint    i;
+
+  path = g_getenv ("_");
+  if (path)
+    {
+      end = strrchr (path, G_DIR_SEPARATOR);
+      if (end && end > path)
+        path = g_strndup (path, end - path);
+      else
+        path = NULL;
+    }
+
   file_list = g_string_prepend (file_list, "gimp\n");
   argv = g_strsplit (file_list->str, "\n", 0);
   g_string_free (file_list, TRUE);
@@ -192,10 +205,25 @@
       if (g_strncasecmp ("file:", argv[i], 5) == 0)
 	argv[i] += 5;
     }
+
+  if (path)
+    {
+      gchar *gimp; 
+
+      gimp = g_strconcat (path, G_DIR_SEPARATOR_S, "gimp", NULL);
+      g_free (path);
+
+      execv (gimp, argv);
+
+      /*  if execv() returns, we try again using execvp()  */
+      g_free (gimp);
+    }
+
   execvp ("gimp", argv);
-	  
-  /*  if execvp returns, there was an arror  */
-  g_printerr ("Couldn't start gimp for the following reason: %s\n", g_strerror (errno));
+
+  /*  if execvp() returns, there was an error  */
+  g_printerr ("Couldn't start gimp for the following reason: %s\n", 
+              g_strerror (errno));
   exit (-1);
 }
 
@@ -249,7 +277,7 @@
     GString  *file_list = g_string_new ("");
     gchar    *cwd       = g_get_current_dir();
     gchar    *file_uri  = "";
-    guint    i;
+    guint     i;
 
     for (i = 1; i < argc; i++)
       {
