Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process results in inconsistent, behavior between GNU/Linux and macOS

From: Eli Zaretskii <[email-masked]>
Date: Sat, 22 May 2021 15:20:58 +0300

> Cc: [email-masked], [email-masked]
> From: Daniel Mendler <[email-masked]>
> Date: Sat, 22 May 2021 13:44:27 +0200
> 
> Both GNU/Linux and macOS are Unixes, it is expected that Emacs behaves
> in the same way on both platforms with regards to handling the current
> directory. When Emacs is started via the command line or via forking
> from another process, Emacs should inherit the default directory from
> the parent process.

If this is what you think, then your concept of the default-directory
is in direct contradiction with how Emacs works.  The cwd of the Emacs
process is immaterial, and actually not even easily visible inside
Emacs.  When a buffer visits a file, Emacs makes a point of behaving
like that file's directory was its cwd.  For other buffers, my
suggestion is to consider their default-directory to be indeterminate,
and if you need it to have a specified value, you should force that by
calling 'cd' or setting default-directory explicitly.  Anything else
is bound to trip you some day, because it simply isn't how Emacs was
designed to behave.

So when you say that Emacs should behave the same on these platforms,
you should first ask yourself what is that "same behavior".  My answer
is simple: you cannot predict what is the default-directory of a
random buffer that doesn't visit a file.  In this sense, Emacs indeed
works the same on all platforms.  Any other sense you may wish to
assign to that is simply a basic mistake.