1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

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.
This commit is contained in:
Paul Eggert 2025-07-24 05:32:37 -07:00
parent 67ea9485a6
commit d59fe6dad5

View file

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