From: Paul Eggert Date: Thu, 24 Jul 2025 12:32:37 +0000 (-0700) Subject: Treat ‘.../emacs’ like ‘emacs’ in realpath startup X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=54d85f123e1a103f3e491cd8310d5d4c1b4f4b15;p=emacs.git Treat ‘.../emacs’ like ‘emacs’ in realpath startup * 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) --- diff --git a/src/emacs.c b/src/emacs.c index 0e10398dc78..3689c92c8b2 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -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; }