]> git.eshelyaron.com Git - emacs.git/commitdiff
Treat ‘.../emacs’ like ‘emacs’ in realpath startup
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 24 Jul 2025 12:32:37 +0000 (05:32 -0700)
committerEshel Yaron <me@eshelyaron.com>
Fri, 25 Jul 2025 20:14:23 +0000 (22:14 +0200)
* src/emacs.c (find_emacs_executable): If the executable name
contains a slash, use the same optimization for symlink resolution
that we already use when the executable name has no slash.

(cherry picked from commit d59fe6dad5667720b296569d2f6fe1b84d42fd0a)

src/emacs.c

index 0e10398dc78bd0def963d7b47a277e95682a0d74..3689c92c8b281738a0e14e39e489ada6d2a39cf8 100644 (file)
@@ -767,15 +767,11 @@ find_emacs_executable (char const *argv0, ptrdiff_t *candidate_size)
   eassert (argv0);
   if (strchr (argv0, DIRECTORY_SEP))
     {
-      char *real_name = realpath (argv0, NULL);
-
-      if (real_name)
-       {
-         *candidate_size = strlen (real_name) + 1;
-         return real_name;
-       }
-
-      char *val = xstrdup (argv0);
+      char *val = (readlink (argv0, linkbuf, sizeof linkbuf) < 0
+                  ? NULL
+                  : realpath (argv0, NULL));
+      if (!val)
+       val = xstrdup (argv0);
       *candidate_size = strlen (val) + 1;
       return val;
     }